1  /-
  2  Copyright (c) 2017 Johannes Hölzl. All rights reserved.
  3  Released under Apache 2.0 license as described in the file LICENSE.
  4  Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov
  5  -/
  6  import tactic.tfae
src         └─────────┘
  7  import order.liminf_limsup
src         └─────────────────┘
  8  import data.set.intervals
src         └────────────────┘
  9  import topology.algebra.group
src         └────────────────────┘
 10  import topology.constructions
src         └────────────────────┘
 11  
 12  /-! # Theory of topology on ordered spaces
 13  
 14  ## Main definitions
 15  
 16  The order topology on an ordered space is the topology generated by all open intervals (or
 17  equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `preorder.topology α`.
 18  However, we do *not* register it as an instance (as many existing ordered types already have
 19  topologies, which would be equal but not definitionally equal to `preorder.topology α`). Instead,
 20  we introduce a class `order_topology α`(which is a `Prop`, also known as a mixin) saying that on
 21  the type `α` having already a topological space structure and a preorder structure, the topological
 22  structure is equal to the order topology.
 23  
 24  We also introduce another (mixin) class `order_closed_topology α` saying that the set of points
 25  `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear
 26  order with the order topology.
 27  
 28  We prove many basic properties of such topologies.
 29  
 30  ## Main statements
 31  
 32  This file contains the proofs of the following facts. For exact requirements (`order_closed_topology`
 33  vs `order_topology`, `preorder` vs `partial_order` vs `linear_order` etc) see their statements.
 34  
 35  ### Open / closed sets
 36  
 37  * `is_open_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open;
 38  * `is_open_Iio`, `is_open_Ioi`, `is_open_Ioo` : open intervals are open;
 39  * `is_closed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed;
 40  * `is_closed_Iic`, `is_closed_Ici`, `is_closed_Icc` : closed intervals are closed;
 41  * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}`
 42    and `{x | f x < g x}` are included by `{x | f x = g x}`;
 43  * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any
 44    neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood
 45    of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`.
 46  
 47  ### Convergence and inequalities
 48  
 49  * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually
 50    `f x ≤ g x`, then `a ≤ b`
 51  * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b`
 52    (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a);
 53  
 54  ### Min, max, `Sup` and `Inf`
 55  
 56  * `continuous.min`, `continuous.max`: pointwise `min`/`max` of two continuous functions is continuous.
 57  * `tendsto.min`, `tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise
 58    `min`/`max` tend to `min a b` and `max a b`, respectively.
 59  * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem,
 60    sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h`
 61    both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`.
 62  
 63  ### Connected sets and Intermediate Value Theorem
 64  
 65  * `is_connected_I??` : all intervals `I??` are connected,
 66  * `is_connected.intermediate_value`, `intermediate_value_univ` : Intermediate Value Theorem for
 67    connected sets and connected spaces, respectively;
 68  * `intermediate_value_Icc`, `intermediate_value_Icc'`: Intermediate Value Theorem for functions
 69    on closed intervals.
 70  
 71  ### Miscellaneous facts
 72  
 73  * `compact.exists_forall_le`, `compact.exists_forall_ge` : extreme value theorem, a continuous
 74    function on a compact set takes its minimum and maximum values.
 75  * `is_closed.Icc_subset_of_forall_mem_nhds_within` : “Continuous induction” principle;
 76    if `s ∩ [a, b]` is closed, `a ∈ s`, and for each `x ∈ [a, b) ∩ s` some of its right neighborhoods
 77    is included `s`, then `[a, b] ⊆ s`.
 78  * `is_closed.Icc_subset_of_forall_exists_gt`, `is_closed.mem_of_ge_of_forall_exists_gt` : two
 79    other versions of the “continuous induction” principle.
 80  
 81  ## Implementation
 82  
 83  We do _not_ register the order topology as an instance on a preorder (or even on a linear order).
 84  Indeed, on many such spaces, a topology has already been constructed in a different way (think
 85  of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`),
 86  and is in general not defeq to the one generated by the intervals. We make it available as a
 87  definition `preorder.topology α` though, that can be registered as an instance when necessary, or
 88  for specific types.
 89  -/
 90  
 91  open classical set lattice filter topological_space
 92  open_locale topological_space classical
 93  
 94  universes u v w
 95  variables {α : Type u} {β : Type v} {γ : Type w}
id             
typ            
 96  
 97  /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the
 98  set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin.
 99  This property is satisfied for the order topology on a linear order, but it can be satisfied more
100  generally, and suffices to derive many interesting properties relating order and topology. -/
101  class order_closed_topology (α : Type*) [topological_space α] [preorder α] : Prop :=
id                                    └───┘   └───────────────┘    └──────┘ 
src                                           └───────────────┘     └──────┘
typ                                   └───┘   └───────────────┘    └──────┘ 
doc                                           └───────────────┘
102  (is_closed_le' : is_closed (λp:α×α, p.1 ≤ p.2))
id                    └───────┘          
src                   └───────┘              
typ                   └───────┘          
doc                   └───────┘
103  
104  instance : Π [topological_space α], topological_space (order_dual α) := id
id                 └───────────────┘    └───────────────┘  └────────┘      └┘
src                └───────────────┘     └───────────────┘  └────────┘       └┘
typ                └───────────────┘    └───────────────┘  └────────┘      └┘
doc                └───────────────┘     └───────────────┘  └────────┘
st                                  
105  
106  section order_closed_topology
107  
108  section preorder
109  variables [topological_space α] [preorder α] [t : order_closed_topology α]
id              └───────────────┘    └──────┘         └───────────────────┘
src             └───────────────┘     └──────┘         └───────────────────┘
typ             └───────────────┘    └──────┘         └───────────────────┘
doc             └───────────────┘                      └───────────────────┘
110  include t
111  
112  lemma is_closed_le [topological_space β] {f g : β → α} (hf : continuous f) (hg : continuous g) :
id                       └───────────────┘                     └────────┘         └────────┘ 
src                      └───────────────┘                        └────────┘          └────────┘
typ                      └───────────────┘                     └────────┘         └────────┘ 
doc                      └───────────────┘                        └────────┘          └────────┘
113    is_closed {b | f b ≤ g b} :=
id     └───────┘        
src    └───────┘         
typ    └───────┘        
doc    └───────┘
114  continuous_iff_is_closed.mp (hf.prod_mk hg) _ t.is_closed_le'
id   └──────────────────────┘└─┘  └┘└──────┘ └┘    └────────────┘
src  └──────────────────────┘└─┘    └──────┘        └────────────┘
typ  └──────────────────────┘└─┘  └┘└──────┘ └┘    └────────────┘
115  
116  lemma is_closed_le' (a : α) : is_closed {b | b ≤ a} :=
id                                └───────┘      
src                                └───────┘       
typ                               └───────┘      
doc                                └───────┘
117  is_closed_le continuous_id continuous_const
id   └──────────┘ └───────────┘ └──────────────┘
src  └──────────┘ └───────────┘ └──────────────┘
typ  └──────────┘ └───────────┘ └──────────────┘
118  
119  lemma is_closed_Iic {a : α} : is_closed (Iic a) :=
id                                └───────┘  └─┘ 
src                                └───────┘  └─┘
typ                               └───────┘  └─┘ 
doc                                └───────┘  └─┘
120  is_closed_le' a
id   └───────────┘ 
src  └───────────┘
typ  └───────────┘ 
121  
122  lemma is_closed_ge' (a : α) : is_closed {b | a ≤ b} :=
id                                └───────┘      
src                                └───────┘       
typ                               └───────┘      
doc                                └───────┘
123  is_closed_le continuous_const continuous_id
id   └──────────┘ └──────────────┘ └───────────┘
src  └──────────┘ └──────────────┘ └───────────┘
typ  └──────────┘ └──────────────┘ └───────────┘
124  
125  lemma is_closed_Ici {a : α} : is_closed (Ici a) :=
id                                └───────┘  └─┘ 
src                                └───────┘  └─┘
typ                               └───────┘  └─┘ 
doc                                └───────┘  └─┘
126  is_closed_ge' a
id   └───────────┘ 
src  └───────────┘
typ  └───────────┘ 
127  
128  instance : order_closed_topology (order_dual α) :=
id              └───────────────────┘  └────────┘ 
src             └───────────────────┘  └────────┘
typ             └───────────────────┘  └────────┘ 
doc             └───────────────────┘  └────────┘
129  ⟨continuous_swap _ (@order_closed_topology.is_closed_le' α _ _ _)⟩
id    └─────────────┘     └─────────────────────────────────┘ 
src   └─────────────┘     └─────────────────────────────────┘
typ   └─────────────┘     └─────────────────────────────────┘ 
130  
131  lemma is_closed_Icc {a b : α} : is_closed (Icc a b) :=
id                                  └───────┘  └─┘  
src                                  └───────┘  └─┘
typ                                 └───────┘  └─┘  
doc                                  └───────┘  └─┘
132  is_closed_inter is_closed_Ici is_closed_Iic
id   └─────────────┘ └───────────┘ └───────────┘
src  └─────────────┘ └───────────┘ └───────────┘
typ  └─────────────┘ └───────────┘ └───────────┘
133  
134  lemma le_of_tendsto_of_tendsto {f g : β → α} {b : filter β} {a₁ a₂ : α} (hb : b ≠ ⊥)
id                                                   └────┘                      
src                                                    └────┘                         
typ                                                  └────┘                      
135    (hf : tendsto f b (𝓝 a₁)) (hg : tendsto g b (𝓝 a₂)) (h : ∀ᶠ x in b, f x ≤ g x) :
id           └─────┘     └┘         └─────┘     └┘        └┘  └┘      
src          └─────┘                  └─────┘                 └┘   └┘       
typ          └─────┘     └┘         └─────┘     └┘        └┘  └┘      
doc          └─────┘                  └─────┘                 └┘   └┘  
136    a₁ ≤ a₂ :=
id     └┘  └┘
src       
typ    └┘  └┘
137  have tendsto (λb, (f b, g b)) b (𝓝 (a₁, a₂)),
id        └─────┘               └┘  └┘
src       └─────┘                     
typ       └─────┘               └┘  └┘
doc       └─────┘                     
138    by rw [nhds_prod_eq]; exact hf.prod_mk hg,
id            └──────────┘         └────────┘ └┘
src       └──┘└──────────┘  └────┘└────────┘
typ       └──┘└──────────┘  └────┘└────────┘└┘
doc       └──┘              └────┘          
txt       └──┘              └────┘          
par       └──┘              └────┘          
pid         └┘                             
st       └───────────────┘└───────────────────┘
139  show (a₁, a₂) ∈ {p:α×α | p.1 ≤ p.2},
id        └┘  └┘           
src                            
typ       └┘  └┘           
140    from mem_of_closed_of_tendsto hb this t.is_closed_le' h
id          └──────────────────────┘ └┘ └──┘ └────────────┘ 
src         └──────────────────────┘          └────────────┘
typ         └──────────────────────┘ └┘ └──┘ └────────────┘ 
141  
142  lemma le_of_tendsto {f : β → α} {a b : α} {x : filter β}
id                                               └────┘ 
src                                                 └────┘
typ                                              └────┘ 
143    (nt : x ≠ ⊥) (lim : tendsto f x (𝓝 a)) (h : f ⁻¹' {c | c ≤ b} ∈ x) : a ≤ b :=
id                      └─────┘              └─┘               
src                      └─────┘                  └─┘                   
typ                     └─────┘              └─┘               
doc                        └─────┘                  └─┘
144  le_of_tendsto_of_tendsto nt lim tendsto_const_nhds h
id   └──────────────────────┘ └┘ └─┘ └────────────────┘ 
src  └──────────────────────┘    └─┘ └────────────────┘
typ  └──────────────────────┘ └┘ └─┘ └────────────────┘ 
doc                              └─┘
145  
146  lemma ge_of_tendsto {f : β → α} {a b : α} {x : filter β}
id                                               └────┘ 
src                                                 └────┘
typ                                              └────┘ 
147    (nt : x ≠ ⊥) (lim : tendsto f x (𝓝 a)) (h : f ⁻¹' {c | b ≤ c} ∈ x) : b ≤ a :=
id                      └─────┘              └─┘               
src                      └─────┘                  └─┘                   
typ                     └─────┘              └─┘               
doc                        └─────┘                  └─┘
148  le_of_tendsto_of_tendsto nt tendsto_const_nhds lim h
id   └──────────────────────┘ └┘ └────────────────┘ └─┘ 
src  └──────────────────────┘    └────────────────┘ └─┘
typ  └──────────────────────┘ └┘ └────────────────┘ └─┘ 
doc                                                 └─┘
149  
150  @[simp] lemma closure_le_eq [topological_space β] {f g : β → α} (hf : continuous f) (hg : continuous g) :
id                                └───────────────┘                     └────────┘         └────────┘ 
src                               └───────────────┘                        └────────┘          └────────┘
typ                               └───────────────┘                     └────────┘         └────────┘ 
doc    └──┘                       └───────────────┘                        └────────┘          └────────┘
151    closure {b | f b ≤ g b} = {b | f b ≤ g b} :=
id     └─────┘                  
src    └─────┘                        
typ    └─────┘                  
doc    └─────┘
152  closure_eq_iff_is_closed.mpr $ is_closed_le hf hg
id   └──────────────────────┘└──┘   └──────────┘ └┘ └┘
src  └──────────────────────┘└──┘   └──────────┘
typ  └──────────────────────┘└──┘   └──────────┘ └┘ └┘
153  
154  lemma closure_lt_subset_le [topological_space β] {f g : β → α} (hf : continuous f) (hg : continuous g) :
id                               └───────────────┘                     └────────┘         └────────┘ 
src                              └───────────────┘                        └────────┘          └────────┘
typ                              └───────────────┘                     └────────┘         └────────┘ 
doc                              └───────────────┘                        └────────┘          └────────┘
155    closure {b | f b < g b} ⊆ {b | f b ≤ g b} :=
id     └─────┘                  
src    └─────┘                        
typ    └─────┘                  
doc    └─────┘
156  by { rw [←closure_le_eq hf hg], exact closure_mono (λ b, le_of_lt) }
id             └───────────┘ └┘ └┘         └──────────┘       └──────┘
src       └───┘└───────────┘      └────┘└──────────┘  └──┘└──────┘└┘
typ       └───┘└───────────┘└┘└┘  └────┘└──────────┘  └──┘└──────┘└┘
doc       └───┘                   └────┘              └──┘        └┘
txt       └───┘                   └────┘              └──┘        └┘
par       └───┘                   └────┘              └──┘        └┘
pid         └─┘                                      └──┘        
st     └─────────────────────────┘└────────────────────────────────────┘└┘
157  
158  lemma continuous_within_at.closure_le [topological_space β]
id                                          └───────────────┘ 
src                                         └───────────────┘
typ                                         └───────────────┘ 
doc                                         └───────────────┘
159   {f g : β → α} {s : set β} {x : β} (hx : x ∈ closure s)
id                     └─┘                  └─────┘ 
src                      └─┘                     └─────┘
typ                    └─┘                  └─────┘ 
doc                                               └─────┘
160   (hf : continuous_within_at f s x)
id          └──────────────────┘   
src         └──────────────────┘
typ         └──────────────────┘   
doc         └──────────────────┘
161   (hg : continuous_within_at g s x)
id          └──────────────────┘   
src         └──────────────────┘
typ         └──────────────────┘   
doc         └──────────────────┘
162   (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x :=
id                            
src                                
typ                           
163  begin
st   └─────
164    show (f x, g x) ∈ {p : α × α | p.1 ≤ p.2},
id                                
src    └───┘  └┘  └┘└──┘  └─┘ └─┘ └─┘
typ    └───┘ └┘└┘└──┘ └─┘ └─┘ └─┘
doc    └───┘   └┘  └┘  └──┘   └─┘ └─┘  └─┘
txt    └───┘   └┘  └┘  └──┘   └─┘ └─┘  └─┘
par    └───┘   └┘  └┘  └──┘   └─┘ └─┘  └─┘
pid    └───┘   └┘  └┘  └──┘   └─┘ └─┘  └─┘
st   ──────────────────────────────────────────┘└─
165    suffices : (f x, g x) ∈ closure {p : α × α | p.1 ≤ p.2},
id                         └─────┘         
src    └─────────┘  └┘  └┘ └─────┘└──┘   └─┘ └─┘  └─┘
typ    └─────────┘ └┘└┘ └─────┘└──┘  └─┘ └─┘  └─┘
doc    └─────────┘   └┘  └┘ └─────┘ └──┘   └─┘ └─┘  └─┘
txt    └─────────┘   └┘  └┘         └──┘   └─┘ └─┘  └─┘
par    └─────────┘   └┘  └┘         └──┘   └─┘ └─┘  └─┘
pid    └───────┘└┘   └┘  └┘         └──┘   └─┘ └─┘  └─┘
st   ────────────────────────────────────────────────────────┘
166      by rwa ← closure_eq_iff_is_closed.2 (order_closed_topology.is_closed_le' α),
id                └──────────────────────┘    └─────────────────────────────────┘ 
src         └────┘└──────────────────────┘└─┘ └─────────────────────────────────┘ 
typ         └────┘└──────────────────────┘└─┘ └─────────────────────────────────┘
doc         └────┘                        └─┘                                     
txt         └────┘                        └─┘                                     
par         └────┘                        └─┘                                     
pid            └─┘                        └─┘                                     
st                                                                                  └─
167    exact (continuous_within_at.prod hf hg).mem_closure hx h
id            └───────────────────────┘ └┘ └┘              └┘ 
src    └────┘ └───────────────────────┘    └────────────┘   
typ    └────┘ └───────────────────────┘└┘└┘└────────────┘└┘
doc    └────┘                              └────────────┘   
txt    └────┘                              └────────────┘   
par    └────┘                              └────────────┘   
pid                                       └────────────┘   
st   ──────────────────────────────────────────────────────────┘
168  end
st   └─┘
169  
170  end preorder
171  
172  section partial_order
173  variables [topological_space α] [partial_order α] [t : order_closed_topology α]
id              └───────────────┘     └───────────┘         └───────────────────┘
src             └───────────────┘     └───────────┘         └───────────────────┘
typ             └───────────────┘     └───────────┘         └───────────────────┘
doc             └───────────────┘                           └───────────────────┘
174  include t
175  
176  private lemma is_closed_eq : is_closed {p : α × α | p.1 = p.2} :=
id                                └───────┘             
src                               └───────┘                 
typ                               └───────┘             
doc                               └───────┘
177  by simp [le_antisymm_iff];
id            └─────────────┘
src     └────┘└─────────────┘
typ     └────┘└─────────────┘
doc     └────┘               
txt     └────┘               
par     └────┘               
pid                        
st     └────────────────────────
178     exact is_closed_inter t.is_closed_le' (is_closed_le continuous_snd continuous_fst)
id            └─────────────┘ └─────────────┘  └──────────┘ └────────────┘ └────────────┘
src     └────┘└─────────────┘└─────────────┘ └──────────┘└────────────┘└────────────┘└─
typ     └────┘└─────────────┘└─────────────┘ └──────────┘└────────────┘└────────────┘└─
doc     └────┘                                                                       └─
txt     └────┘                                                                       └─
par     └────┘                                                                       └─
pid                                                                                 
st   ──────────────────────────────────────────────────────────────────────────────────────
179  
src  
typ  
doc  
txt  
par  
pid  
st   
180  @[priority 90] -- see Note [lower instance priority]
181  instance order_closed_topology.to_t2_space : t2_space α :=
id                                                └──────┘ 
src                                               └──────┘
typ                                               └──────┘ 
doc                                               └──────┘
182  { t2 :=
183    have is_open {p : α × α | p.1 ≠ p.2}, from is_closed_eq,
id          └─────┘                      └──────────┘
src         └─────┘                          └──────────┘
typ         └─────┘                      └──────────┘
doc         └─────┘
184    assume a b h,
id              
typ             
185    let ⟨u, v, hu, hv, ha, hb, h⟩ := is_open_prod_iff.mp this a b h in
id     └─┘      └┘  └┘  └┘  └┘       └──────────────┘└─┘ └──┘   
src                                     └──────────────┘└─┘
typ    └─┘      └┘  └┘  └┘  └┘       └──────────────┘└─┘ └──┘   
186    ⟨u, v, hu, hv, ha, hb,
187      set.eq_empty_iff_forall_not_mem.2 $ assume a ⟨h₁, h₂⟩,
id       └─────────────────────────────┘            └┘  └┘
src      └─────────────────────────────┘
typ      └─────────────────────────────┘            └┘  └┘
188      have a ≠ a, from @h (a, a) ⟨h₁, h₂⟩,
id                          
src                         
typ                         
189      this rfl⟩ }
id       └──┘ └─┘
src           └─┘
typ      └──┘ └─┘
190  
191  end partial_order
192  
193  section linear_order
194  variables [topological_space α] [linear_order α] [order_closed_topology α]
id              └───────────────┘     └──────────┘     └───────────────────┘
src             └───────────────┘     └──────────┘     └───────────────────┘
typ             └───────────────┘     └──────────┘     └───────────────────┘
doc             └───────────────┘                      └───────────────────┘
195  
196  lemma is_open_lt [topological_space β] {f g : β → α} (hf : continuous f) (hg : continuous g) :
id                     └───────────────┘                     └────────┘         └────────┘ 
src                    └───────────────┘                        └────────┘          └────────┘
typ                    └───────────────┘                     └────────┘         └────────┘ 
doc                    └───────────────┘                        └────────┘          └────────┘
197    is_open {b | f b < g b} :=
id     └─────┘        
src    └─────┘         
typ    └─────┘        
doc    └─────┘
198  by simp [lt_iff_not_ge, -not_le]; exact is_closed_le hg hf
id            └───────────┘                  └──────────┘ └┘ └┘
src     └────┘└───────────┘└────────┘  └────┘└──────────┘    
typ     └────┘└───────────┘└────────┘  └────┘└──────────┘└┘└┘
doc     └────┘             └────────┘  └────┘                
txt     └────┘             └────────┘  └────┘                
par     └────┘             └────────┘  └────┘                
pid                      └────────┘                       
st     └────────────────────────────────────────────────────────
199  
src  
typ  
doc  
txt  
par  
pid  
st   
200  lemma is_open_Iio {a : α} : is_open (Iio a) :=
id                              └─────┘  └─┘ 
src                              └─────┘  └─┘
typ                             └─────┘  └─┘ 
doc                              └─────┘  └─┘
201  is_open_lt continuous_id continuous_const
id   └────────┘ └───────────┘ └──────────────┘
src  └────────┘ └───────────┘ └──────────────┘
typ  └────────┘ └───────────┘ └──────────────┘
202  
203  lemma is_open_Ioi {a : α} : is_open (Ioi a) :=
id                              └─────┘  └─┘ 
src                              └─────┘  └─┘
typ                             └─────┘  └─┘ 
doc                              └─────┘  └─┘
204  is_open_lt continuous_const continuous_id
id   └────────┘ └──────────────┘ └───────────┘
src  └────────┘ └──────────────┘ └───────────┘
typ  └────────┘ └──────────────┘ └───────────┘
205  
206  lemma is_open_Ioo {a b : α} : is_open (Ioo a b) :=
id                                └─────┘  └─┘  
src                                └─────┘  └─┘
typ                               └─────┘  └─┘  
doc                                └─────┘  └─┘
207  is_open_inter is_open_Ioi is_open_Iio
id   └───────────┘ └─────────┘ └─────────┘
src  └───────────┘ └─────────┘ └─────────┘
typ  └───────────┘ └─────────┘ └─────────┘
208  
209  lemma is_connected.forall_Icc_subset {s : set α} (hs : is_connected s)
id                                             └─┘         └──────────┘ 
src                                            └─┘          └──────────┘
typ                                            └─┘         └──────────┘ 
doc                                                         └──────────┘
210    {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
id                                
src                                  
typ                               
211    Icc a b ⊆ s :=
id     └─┘    
src    └─┘     
typ    └─┘    
doc    └─┘
212  begin
st   └─────
213    assume x hx,
src    └─────────┘
typ    └─────────┘
doc    └─────────┘
txt    └─────────┘
par    └─────────┘
pid    └─────────┘
st   ────────────┘└─
214    obtain ⟨y, hy, hy'⟩ : (s ∩ ((Iic x) ∩ (Ici x))).nonempty,
id                                └─┘       └─┘ 
src    └────────────────────┘    └─┘ └┘  └─┘ └──────────┘
typ    └────────────────────┘   └─┘ └┘  └─┘└──────────┘
doc    └────────────────────┘     └─┘ └┘  └─┘ └──────────┘
txt    └────────────────────┘         └┘      └──────────┘
par    └────────────────────┘         └┘      └──────────┘
pid          └──────────────┘         └┘      └─────────┘
st   ─────────────────────────────────────────────────────────┘└─
215      from is_connected_closed_iff.1 hs (Iic x) (Ici x) is_closed_Iic is_closed_Ici
id            └─────────────────────┘   └┘  └─┘     └─┘    └───────────┘ └───────────┘
src      └───┘└─────────────────────┘└─┘   └─┘ └┘ └─┘ └┘└───────────┘└───────────┘
typ      └───┘└─────────────────────┘└─┘└┘ └─┘ └┘ └─┘ └┘└───────────┘└───────────┘
doc      └───┘                       └─┘   └─┘ └┘ └─┘ └┘                          
txt      └───┘                       └─┘       └┘     └┘                          
par      └───┘                       └─┘       └┘     └┘                          
pid      └───┘                       └─┘       └┘     └┘                          
st   ──────────────────────────────────────────────────────────────────────────────────
216        (λ y _, le_total y x) ⟨a, ha, hx.1⟩ ⟨b, hb, hx.2⟩,
id                 └──────┘        └┘           └┘  └┘
src  ─────┘  └────┘└──────┘  └┘  └┘  └┘  └──┘  └┘  └┘  └─┘
typ  ─────┘  └────┘└──────┘ └┘ └┘└┘└┘  └──┘ └┘└┘└┘└┘└─┘
doc  ─────┘  └────┘          └┘  └┘  └┘  └──┘  └┘  └┘  └─┘
txt  ─────┘  └────┘          └┘  └┘  └┘  └──┘  └┘  └┘  └─┘
par  ─────┘  └────┘          └┘  └┘  └┘  └──┘  └┘  └┘  └─┘
pid  ─────┘  └────┘          └┘  └┘  └┘  └──┘  └┘  └┘  └─┘
st   ──────────────────────────────────────────────────────┘└─
217    exact le_antisymm hy'.1 hy'.2 ▸ hy
id           └─────────┘       └─┘    └┘
src    └────┘└─────────┘   └─┘   └─┘  
typ    └────┘└─────────┘   └─┘└─┘└─┘└┘
doc    └────┘              └─┘   └─┘   
txt    └────┘              └─┘   └─┘   
par    └────┘              └─┘   └─┘   
pid                       └─┘   └─┘   
st   ────────────────────────────────────┘
218  end
st   └─┘
219  
220  /-- Intermediate Value Theorem for continuous functions on connected sets. -/
221  lemma is_connected.intermediate_value {γ : Type*} [topological_space γ] {s : set γ}
id                                                      └───────────────┘        └─┘ 
src                                                     └───────────────┘         └─┘
typ                                                     └───────────────┘        └─┘ 
doc                                                     └───────────────┘
222    (hs : is_connected s) {a b : γ} (ha : a ∈ s) (hb : b ∈ s) {f : γ → α} (hf : continuous_on f s) :
id           └──────────┘                                                └───────────┘  
src          └──────────┘                                                        └───────────┘
typ          └──────────┘                                                └───────────┘  
doc          └──────────┘                                                          └───────────┘
223    Icc (f a) (f b) ⊆ f '' s :=
id     └─┘           └┘ 
src    └─┘                └┘
typ    └─┘           └┘ 
doc    └─┘
224  (hs.image f hf).forall_Icc_subset (mem_image_of_mem f ha) (mem_image_of_mem f hb)
id    └┘└────┘  └┘ └───────────────┘   └──────────────┘  └┘   └──────────────┘  └┘
src     └────┘      └───────────────┘   └──────────────┘        └──────────────┘
typ   └┘└────┘  └┘ └───────────────┘   └──────────────┘  └┘   └──────────────┘  └┘
225  
226  /-- Intermediate Value Theorem for continuous functions on connected spaces. -/
227  lemma intermediate_value_univ {γ : Type*} [topological_space γ] [H : connected_space γ]
id                                              └───────────────┘        └─────────────┘ 
src                                             └───────────────┘         └─────────────┘
typ                                             └───────────────┘        └─────────────┘ 
doc                                             └───────────────┘         └─────────────┘
228    (a b : γ) {f : γ → α} (hf : continuous f) :
id                              └────────┘ 
src                                └────────┘
typ                             └────────┘ 
doc                                └────────┘
229    Icc (f a) (f b) ⊆ range f :=
id     └─┘          └───┘ 
src    └─┘              └───┘
typ    └─┘          └───┘ 
doc    └─┘               └───┘
230  @image_univ _ _ f ▸ H.is_connected_univ.intermediate_value trivial trivial hf.continuous_on
id    └────────┘       └────────────────┘└─────────────────┘ └─────┘ └─────┘ └┘└────────────┘
src   └────────┘         └────────────────┘└─────────────────┘ └─────┘ └─────┘   └────────────┘
typ   └────────┘       └────────────────┘└─────────────────┘ └─────┘ └─────┘ └┘└────────────┘
doc                                         └─────────────────┘
231  
232  end linear_order
233  
234  section decidable_linear_order
235  variables [topological_space α] [decidable_linear_order α] [order_closed_topology α] {f g : β → α}
id              └───────────────┘     └────────────────────┘     └───────────────────┘
src             └───────────────┘     └────────────────────┘     └───────────────────┘
typ             └───────────────┘     └────────────────────┘     └───────────────────┘
doc             └───────────────┘                                └───────────────────┘
236  
237  section
238  variables [topological_space β] (hf : continuous f) (hg : continuous g)
id              └───────────────┘          └────────┘          └────────┘
src             └───────────────┘          └────────┘          └────────┘
typ             └───────────────┘          └────────┘          └────────┘
doc             └───────────────┘          └────────┘          └────────┘
239  include hf hg
240  
241  lemma frontier_le_subset_eq : frontier {b | f b ≤ g b} ⊆ {b | f b = g b} :=
id                                 └──────┘                  
src                                └──────┘                        
typ                                └──────┘                  
doc                                └──────┘
242  begin
st   └─────
243    rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg],
id         └───────────────────────────────┘  └───────────┘ └┘ └┘
src    └──┘└───────────────────────────────┘└┘└───────────┘    
typ    └──┘└───────────────────────────────┘└┘└───────────┘└┘└┘
doc    └──┘                                 └┘                 
txt    └──┘                                 └┘                 
par    └──┘                                 └┘                 
pid      └┘                                 └┘                 
st   ──────────────────────────────────────┘└───────────────────┘└──
244    rintros b ⟨hb₁, hb₂⟩,
src    └──────────────────┘
typ    └──────────────────┘
doc    └──────────────────┘
txt    └──────────────────┘
par    └──────────────────┘
pid           └───────────┘
st   ─────────────────────┘└─
245    refine le_antisymm hb₁ (closure_lt_subset_le hg hf _),
id            └─────────┘ └─┘  └──────────────────┘ └┘ └┘
src    └─────┘└─────────┘    └──────────────────┘    └─┘
typ    └─────┘└─────────┘└─┘ └──────────────────┘└┘└┘└─┘
doc    └─────┘                                       └─┘
txt    └─────┘                                       └─┘
par    └─────┘                                       └─┘
pid                                                 └─┘
st   ──────────────────────────────────────────────────────┘└─
246    convert hb₂ using 2, simp only [not_le.symm], refl
id             └─┘
src    └──────┘   └──────┘  └─────────┘             └───┘
typ    └──────┘└─┘└──────┘  └─────────┘└─────────┘  └───┘
doc    └──────┘   └──────┘  └─────────┘             └───┘
txt    └──────┘   └──────┘  └─────────┘             └───┘
par    └──────┘   └──────┘  └─────────┘             └───┘
pid              └─────┘      └──┘└┘                 
st   ────────────────────┘└───────────────────────┘└─────┘
247  end
st   └─┘
248  
249  lemma frontier_lt_subset_eq : frontier {b | f b < g b} ⊆ {b | f b = g b} :=
id                                 └──────┘                  
src                                └──────┘                        
typ                                └──────┘                  
doc                                └──────┘
250  by rw ← frontier_compl;
id           └────────────┘
src     └───┘└────────────┘
typ     └───┘└────────────┘
doc     └───┘└────────────┘
txt     └───┘
par     └───┘
pid       └─┘
st     └─────────────────────
251     convert frontier_le_subset_eq hg hf; simp [ext_iff, eq_comm]
id              └───────────────────┘ └┘ └┘        └─────┘  └─────┘
src     └──────┘└───────────────────┘      └────┘└─────┘└┘└─────┘└─
typ     └──────┘└───────────────────┘└┘└┘  └────┘└─────┘└┘└─────┘└─
doc     └──────┘                           └────┘       └┘       └─
txt     └──────┘                           └────┘       └┘       └─
par     └──────┘                           └────┘       └┘       └─
pid                                                  └┘       
st   ────────────────────────────────────────────────────────────────
252  
src  
typ  
doc  
txt  
par  
pid  
st   
253  lemma continuous.max : continuous (λb, max (f b) (g b)) :=
id                          └────────┘     └─┘       
src                         └────────┘      └─┘
typ                         └────────┘     └─┘       
doc                         └────────┘
254  have ∀b∈frontier {b | f b ≤ g b}, g b = f b, from assume b hb, (frontier_le_subset_eq hf hg hb).symm,
id          └──────┘                              └┘   └───────────────────┘ └┘ └┘ └┘ └──┘
src          └──────┘                                             └───────────────────┘          └──┘
typ         └──────┘                              └┘   └───────────────────┘ └┘ └┘ └┘ └──┘
doc          └──────┘
255  continuous_if this hg hf
id   └───────────┘ └──┘ └┘ └┘
src  └───────────┘
typ  └───────────┘ └──┘ └┘ └┘
doc  └───────────┘
256  
257  lemma continuous.min : continuous (λb, min (f b) (g b)) :=
id                          └────────┘     └─┘       
src                         └────────┘      └─┘
typ                         └────────┘     └─┘       
doc                         └────────┘
258  have ∀b∈frontier {b | f b ≤ g b}, f b = g b, from assume b hb, frontier_le_subset_eq hf hg hb,
id          └──────┘                              └┘  └───────────────────┘ └┘ └┘ └┘
src          └──────┘                                            └───────────────────┘
typ         └──────┘                              └┘  └───────────────────┘ └┘ └┘ └┘
doc          └──────┘
259  continuous_if this hf hg
id   └───────────┘ └──┘ └┘ └┘
src  └───────────┘
typ  └───────────┘ └──┘ └┘ └┘
doc  └───────────┘
260  
261  end
262  
263  lemma tendsto.max {b : filter β} {a₁ a₂ : α} (hf : tendsto f b (𝓝 a₁)) (hg : tendsto g b (𝓝 a₂)) :
id                          └────┘                    └─────┘     └┘         └─────┘     └┘
src                         └────┘                      └─────┘                  └─────┘      
typ                         └────┘                    └─────┘     └┘         └─────┘     └┘
doc                                                     └─────┘                  └─────┘      
264    tendsto (λb, max (f b) (g b)) b (𝓝 (max a₁ a₂)) :=
id     └─────┘     └─┘              └─┘ └┘ └┘
src    └─────┘      └─┘                   └─┘
typ    └─────┘     └─┘              └─┘ └┘ └┘
doc    └─────┘                          
265  show tendsto ((λp:α×α, max p.1 p.2) ∘ (λb, (f b, g b))) b (𝓝 (max a₁ a₂)),
id        └─────┘        └─┘                       └─┘ └┘ └┘
src       └─────┘          └─┘                               └─┘
typ       └─────┘        └─┘                       └─┘ └┘ └┘
doc       └─────┘                                               
266    from tendsto.comp
id          └──────────┘
src         └──────────┘
typ         └──────────┘
267      begin
st       └─────
268        rw [←nhds_prod_eq],
id              └──────────┘
src        └───┘└──────────┘
typ        └───┘└──────────┘
doc        └───┘            
txt        └───┘            
par        └───┘            
pid          └─┘            
st   ──────────────────────┘└──
269        from continuous_iff_continuous_at.mp (continuous_fst.max continuous_snd) _
id              └─────────────────────────────┘  └────────────────┘ └────────────┘
src        └───┘└─────────────────────────────┘ └────────────────┘└────────────┘└───
typ        └───┘└─────────────────────────────┘ └────────────────┘└────────────┘└───
doc        └───┘                                                                └───
txt        └───┘                                                                └───
par        └───┘                                                                └───
pid        └───┘                                                                └─┘
st   ─────────────────────────────────────────────────────────────────────────────────
270      end
src  ───┘
typ  ───┘
doc  ───┘
txt  ───┘
par  ───┘
pid  ───┘
st   ───┘└─┘
271      (hf.prod_mk hg)
id        └┘└──────┘ └┘
src         └──────┘
typ       └┘└──────┘ └┘
272  
273  lemma tendsto.min {b : filter β} {a₁ a₂ : α} (hf : tendsto f b (𝓝 a₁)) (hg : tendsto g b (𝓝 a₂)) :
id                          └────┘                    └─────┘     └┘         └─────┘     └┘
src                         └────┘                      └─────┘                  └─────┘      
typ                         └────┘                    └─────┘     └┘         └─────┘     └┘
doc                                                     └─────┘                  └─────┘      
274    tendsto (λb, min (f b) (g b)) b (𝓝 (min a₁ a₂)) :=
id     └─────┘     └─┘              └─┘ └┘ └┘
src    └─────┘      └─┘                   └─┘
typ    └─────┘     └─┘              └─┘ └┘ └┘
doc    └─────┘                          
275  show tendsto ((λp:α×α, min p.1 p.2) ∘ (λb, (f b, g b))) b (𝓝 (min a₁ a₂)),
id        └─────┘        └─┘                       └─┘ └┘ └┘
src       └─────┘          └─┘                               └─┘
typ       └─────┘        └─┘                       └─┘ └┘ └┘
doc       └─────┘                                               
276    from tendsto.comp
id          └──────────┘
src         └──────────┘
typ         └──────────┘
277      begin
st       └─────
278        rw [←nhds_prod_eq],
id              └──────────┘
src        └───┘└──────────┘
typ        └───┘└──────────┘
doc        └───┘            
txt        └───┘            
par        └───┘            
pid          └─┘            
st   ──────────────────────┘└──
279        from continuous_iff_continuous_at.mp (continuous_fst.min continuous_snd) _
id              └─────────────────────────────┘  └────────────────┘ └────────────┘
src        └───┘└─────────────────────────────┘ └────────────────┘└────────────┘└───
typ        └───┘└─────────────────────────────┘ └────────────────┘└────────────┘└───
doc        └───┘                                                                └───
txt        └───┘                                                                └───
par        └───┘                                                                └───
pid        └───┘                                                                └─┘
st   ─────────────────────────────────────────────────────────────────────────────────
280      end
src  ───┘
typ  ───┘
doc  ───┘
txt  ───┘
par  ───┘
pid  ───┘
st   ───┘└─┘
281      (hf.prod_mk hg)
id        └┘└──────┘ └┘
src         └──────┘
typ       └┘└──────┘ └┘
282  
283  end decidable_linear_order
284  
285  end order_closed_topology
286  
287  /-- The order topology on an ordered type is the topology generated by open intervals. We register
288  it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed.
289  We define it as a mixin. If you want to introduce the order topology on a preorder, use
290  `preorder.topology`. -/
291  class order_topology (α : Type*) [t : topological_space α] [preorder α] : Prop :=
id                             └───┘       └───────────────┘    └──────┘ 
src                                        └───────────────┘     └──────┘
typ                            └───┘       └───────────────┘    └──────┘ 
doc                                        └───────────────┘
292  (topology_eq_generate_intervals : t = generate_from {s | ∃a, s = Ioi a ∨ s = Iio a})
id                                       └───────────┘       └─┘     └─┘ 
src                                       └───────────┘          └─┘       └─┘
typ                                      └───────────┘       └─┘     └─┘ 
doc                                        └───────────┘              └─┘         └─┘
293  
294  /-- (Order) topology on a partial order `α` generated by the subbase of open intervals
295  `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an
296  instance as many ordered sets are already endowed with the same topology, most often in a non-defeq
297  way though. Register as a local instance when necessary. -/
298  def preorder.topology (α : Type*) [preorder α] : topological_space α :=
id                                      └──────┘     └───────────────┘ 
src                                     └──────┘      └───────────────┘
typ                                     └──────┘     └───────────────┘ 
doc                                                   └───────────────┘
299  generate_from {s : set α | ∃ (a : α), s = {b : α | a < b} ∨ s = {b : α | b < a}}
id   └───────────┘     └─┘                                     
src  └───────────┘     └─┘                                             
typ  └───────────┘     └─┘                                     
doc  └───────────┘
300  
301  section order_topology
302  
303  instance {α : Type*} [topological_space α] [partial_order α] [order_topology α] :
id                         └───────────────┘    └───────────┘    └────────────┘ 
src                        └───────────────┘     └───────────┘     └────────────┘
typ                        └───────────────┘    └───────────┘    └────────────┘ 
doc                        └───────────────┘                       └────────────┘
304    order_topology (order_dual α) :=
id     └────────────┘  └────────┘ 
src    └────────────┘  └────────┘
typ    └────────────┘  └────────┘ 
doc    └────────────┘  └────────┘
305  ⟨by convert @order_topology.topology_eq_generate_intervals α _ _ _;
id                └───────────────────────────────────────────┘ 
src      └──────┘ └───────────────────────────────────────────┘ └────┘
typ      └──────┘ └───────────────────────────────────────────┘└────┘
doc      └──────┘                                               └────┘
txt      └──────┘                                               └────┘
par      └──────┘                                               └────┘
pid                                                            └────┘
st      └────────────────────────────────────────────────────────────────
306    conv in (_ ∨ _) { rw or.comm }; refl⟩
id                          └─────┘
src    └──────┘ └┘ └────┘└─┘└─────┘  └──┘
typ    └──────┘ └┘ └────┘└─┘└─────┘  └──┘
doc                                    └──┘
txt    └──────┘ └┘ └────┘└─┘         └──┘
par    └──────┘ └┘ └────┘└─┘         └──┘
pid        └─┘ └┘ └─┘└────┘       └┘
st   ──────────────────┘└──────────┘└┘└───┘
307  
308  section partial_order
309  variables [topological_space α] [partial_order α] [t : order_topology α]
id              └───────────────┘     └───────────┘         └────────────┘
src             └───────────────┘     └───────────┘         └────────────┘
typ             └───────────────┘     └───────────┘         └────────────┘
doc             └───────────────┘                           └────────────┘
310  include t
311  
312  lemma is_open_iff_generate_intervals {s : set α} :
id                                             └─┘ 
src                                            └─┘
typ                                            └─┘ 
313    is_open s ↔ generate_open {s | ∃a, s = Ioi a ∨ s = Iio a} s :=
id     └─────┘   └───────────┘       └─┘     └─┘   
src    └─────┘    └───────────┘          └─┘       └─┘
typ    └─────┘   └───────────┘       └─┘     └─┘   
doc    └─────┘     └───────────┘              └─┘         └─┘
314  by rw [t.topology_eq_generate_intervals]; refl
src     └──┘                                  └────
typ     └──┘└──────────────────────────────┘  └────
doc     └──┘                                  └────
txt     └──┘                                  └────
par     └──┘                                  └────
pid       └┘                                      
st     └───────────────────────────────────┘└──────
315  
src  
typ  
doc  
txt  
par  
pid  
st   
316  lemma is_open_lt' (a : α) : is_open {b:α | a < b} :=
id                              └─────┘        
src                              └─────┘         
typ                             └─────┘        
doc                              └─────┘
317  by rw [@is_open_iff_generate_intervals α _ _ t]; exact generate_open.basic _ ⟨a, or.inl rfl⟩
id           └────────────────────────────┘               └─────────────────┘      └────┘ └─┘
src     └──┘ └────────────────────────────┘ └───┘   └────┘└─────────────────┘└─┘  └┘└────┘└─┘└─
typ     └──┘ └────────────────────────────┘└───┘  └────┘└─────────────────┘└─┘ └┘└────┘└─┘└─
doc     └──┘                                └───┘   └────┘                   └─┘  └┘         └─
txt     └──┘                                └───┘   └────┘                   └─┘  └┘         └─
par     └──┘                                └───┘   └────┘                   └─┘  └┘         └─
pid       └┘                                └───┘                           └─┘  └┘         
st     └──────────────────────────────────────────┘└─────────────────────────────────────────────
318  
src  
typ  
doc  
txt  
par  
pid  
st   
319  lemma is_open_gt' (a : α) : is_open {b:α | b < a} :=
id                              └─────┘        
src                              └─────┘         
typ                             └─────┘        
doc                              └─────┘
320  by rw [@is_open_iff_generate_intervals α _ _ t]; exact generate_open.basic _ ⟨a, or.inr rfl⟩
id           └────────────────────────────┘               └─────────────────┘      └────┘ └─┘
src     └──┘ └────────────────────────────┘ └───┘   └────┘└─────────────────┘└─┘  └┘└────┘└─┘└─
typ     └──┘ └────────────────────────────┘└───┘  └────┘└─────────────────┘└─┘ └┘└────┘└─┘└─
doc     └──┘                                └───┘   └────┘                   └─┘  └┘         └─
txt     └──┘                                └───┘   └────┘                   └─┘  └┘         └─
par     └──┘                                └───┘   └────┘                   └─┘  └┘         └─
pid       └┘                                └───┘                           └─┘  └┘         
st     └──────────────────────────────────────────┘└─────────────────────────────────────────────
321  
src  
typ  
doc  
txt  
par  
pid  
st   
322  lemma lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x :=
id                                         └┘  └┘     
src                                           └┘   └┘      
typ                                        └┘  └┘     
doc                                            └┘   └┘   
323  mem_nhds_sets (is_open_lt' _) h
id   └───────────┘  └─────────┘    
src  └───────────┘  └─────────┘
typ  └───────────┘  └─────────┘    
324  
325  lemma le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x :=
id                                         └┘  └┘     
src                                           └┘   └┘      
typ                                        └┘  └┘     
doc                                            └┘   └┘   
326  (𝓝 b).sets_of_superset (lt_mem_nhds h) $ assume b hb, le_of_lt hb
id      └──────────────┘   └─────────┘             └┘  └──────┘ └┘
src      └──────────────┘   └─────────┘                   └──────┘
typ     └──────────────┘   └─────────┘             └┘  └──────┘ └┘
doc   
327  
328  lemma gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b :=
id                                         └┘  └┘     
src                                           └┘   └┘      
typ                                        └┘  └┘     
doc                                            └┘   └┘   
329  mem_nhds_sets (is_open_gt' _) h
id   └───────────┘  └─────────┘    
src  └───────────┘  └─────────┘
typ  └───────────┘  └─────────┘    
330  
331  lemma ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b :=
id                                         └┘  └┘     
src                                           └┘   └┘      
typ                                        └┘  └┘     
doc                                            └┘   └┘   
332  (𝓝 a).sets_of_superset (gt_mem_nhds h) $ assume b hb, le_of_lt hb
id      └──────────────┘   └─────────┘             └┘  └──────┘ └┘
src      └──────────────┘   └─────────┘                   └──────┘
typ     └──────────────┘   └─────────┘             └┘  └──────┘ └┘
doc   
333  
334  lemma nhds_eq_order (a : α) :
id                            
typ                           
335    𝓝 a = (⨅b ∈ Iio a, principal (Ioi b)) ⊓ (⨅b ∈ Ioi a, principal (Iio b)) :=
id            └─┘  └───────┘  └─┘         └─┘  └───────┘  └─┘ 
src             └─┘   └───────┘  └─┘           └─┘   └───────┘  └─┘
typ           └─┘  └───────┘  └─┘         └─┘  └───────┘  └─┘ 
doc              └─┘   └───────┘  └─┘            └─┘   └───────┘  └─┘
336  by rw [t.topology_eq_generate_intervals, nhds_generate_from];
id                                            └────────────────┘
src     └──┘                                └┘└────────────────┘
typ     └──┘└──────────────────────────────┘└┘└────────────────┘
doc     └──┘                                └┘                  
txt     └──┘                                └┘                  
par     └──┘                                └┘                  
pid       └┘                                └┘                  
st     └───────────────────────────────────┘└──────────────────┘└─
337  from le_antisymm
id        └─────────┘
src  └───┘└─────────┘
typ  └───┘└─────────┘
doc  └───┘           
txt  └───┘           
par  └───┘           
pid  └───┘           
st   ─────────────────
338    (le_inf
id      └────┘
src  ─┘ └────┘
typ  ─┘ └────┘
doc  ─┘       
txt  ─┘       
par  ─┘       
pid  ─┘       
st   ──────────
339      (le_infi $ assume b, le_infi $ assume hb,
src  ───┘               └──┘              └────
typ  ───┘               └──┘              └────
doc  ───┘               └──┘              └────
txt  ───┘               └──┘              └────
par  ───┘               └──┘              └────
pid  ───┘               └──┘              └────
st   ──────────────────────────────────────────────
340        infi_le_of_le {c : α | b < c} $ infi_le _ ⟨hb, b, or.inl rfl⟩)
id                                                         └────┘
src  ─────┘             └──┘ └─┘  └┘        └─┘   └┘ └┘└────┘   └──
typ  ─────┘             └──┘ └─┘  └┘        └─┘   └┘ └┘└────┘   └──
doc  ─────┘              └──┘ └─┘   └┘        └─┘   └┘ └┘         └──
txt  ─────┘              └──┘ └─┘   └┘        └─┘   └┘ └┘         └──
par  ─────┘              └──┘ └─┘   └┘        └─┘   └┘ └┘         └──
pid  ─────┘              └──┘ └─┘   └┘        └─┘   └┘ └┘         └──
st   ─────────────────────────────────────────────────────────────────────
341      (le_infi $ assume b, le_infi $ assume hb,
src  ───┘               └──┘              └────
typ  ───┘               └──┘              └────
doc  ───┘               └──┘              └────
txt  ───┘               └──┘              └────
par  ───┘               └──┘              └────
pid  ───┘               └──┘              └────
st   ──────────────────────────────────────────────
342        infi_le_of_le {c : α | c < b} $ infi_le _ ⟨hb, b, or.inr rfl⟩))
id                                                          └────┘ └─┘
src  ─────┘              └──┘ └─┘   └┘        └─┘   └┘ └┘└────┘└─┘└───
typ  ─────┘              └──┘└─┘   └┘        └─┘   └┘ └┘└────┘└─┘└───
doc  ─────┘              └──┘ └─┘   └┘        └─┘   └┘ └┘         └───
txt  ─────┘              └──┘ └─┘   └┘        └─┘   └┘ └┘         └───
par  ─────┘              └──┘ └─┘   └┘        └─┘   └┘ └┘         └───
pid  ─────┘              └──┘ └─┘   └┘        └─┘   └┘ └┘         └───
st   ──────────────────────────────────────────────────────────────────────
343    (le_infi $ assume s, le_infi $ assume ⟨ha, b, hs⟩,
id                          └─────┘           └┘    └┘
src  ─┘               └──┘└─────┘       └┘  └┘ └┘  └──
typ  ─┘               └──┘└─────┘       └┘└┘└┘└┘└┘└──
doc  ─┘               └──┘              └┘  └┘ └┘  └──
txt  ─┘               └──┘              └┘  └┘ └┘  └──
par  ─┘               └──┘              └┘  └┘ └┘  └──
pid  ─┘               └──┘              └┘  └┘ └┘  └──
st   ─────────────────────────────────────────────────────
344      match s, ha, hs with
src  ───┘      └┘  └┘  └─────
typ  ───┘      └┘  └┘  └─────
doc  ───┘      └┘  └┘  └─────
txt  ───┘      └┘  └┘  └─────
par  ───┘      └┘  └┘  └─────
pid  ───┘      └┘  └┘  └─────
st   ─────────────────────────
345      | _, h, (or.inl rfl) := inf_le_left_of_le $ infi_le_of_le b $ infi_le _ h
id                              └───────────────┘
src  ────────┘ └┘          └───┘└───────────────┘                       └─┘ 
typ  ────────┘└┘          └───┘└───────────────┘                       └─┘ 
doc  ────────┘ └┘          └───┘                                        └─┘ 
txt  ────────┘ └┘          └───┘                                        └─┘ 
par  ────────┘ └┘          └───┘                                        └─┘ 
pid  ────────┘ └┘          └───┘                                        └─┘ 
st   ──────────────────────────────────────────────────────────────────────────────
346      | _, h, (or.inr rfl) := inf_le_right_of_le $ infi_le_of_le b $ infi_le _ h
id                              └────────────────┘   └───────────┘     └─────┘
src  ────────┘ └┘          └───┘└────────────────┘ └───────────┘  └─────┘└─┘ 
typ  ────────┘└┘          └───┘└────────────────┘ └───────────┘  └─────┘└─┘ 
doc  ────────┘ └┘          └───┘                                         └─┘ 
txt  ────────┘ └┘          └───┘                                         └─┘ 
par  ────────┘ └┘          └───┘                                         └─┘ 
pid  ────────┘ └┘          └───┘                                         └─┘ 
st   ───────────────────────────────────────────────────────────────────────────────
347      end)
src  ─────────
typ  ─────────
doc  ─────────
txt  ─────────
par  ─────────
pid  ───────┘
st   ─────────
348  
src  
typ  
doc  
txt  
par  
pid  
st   
349  @[nolint] -- see Note [nolint_ge]
doc    └────┘
350  lemma tendsto_order {f : β → α} {a : α} {x : filter β} :
id                                             └────┘ 
src                                               └────┘
typ                                            └────┘ 
351    tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ (∀ a' > a, ∀ᶠ b in x, f b < a') :=
id     └─────┘           └┘     └┘  └┘  └┘         └┘     └┘  └┘     └┘
src    └─────┘              └┘      └┘   └┘                └┘      └┘   └┘       
typ    └─────┘           └┘     └┘  └┘  └┘         └┘     └┘  └┘     └┘
doc    └─────┘                       └┘   └┘                          └┘   └┘  
352  by simp [nhds_eq_order a, tendsto_inf, tendsto_infi, tendsto_principal]
id            └───────────┘   └─────────┘  └──────────┘  └───────────────┘
src     └────┘└───────────┘ └┘└─────────┘└┘└──────────┘└┘└───────────────┘└─
typ     └────┘└───────────┘└┘└─────────┘└┘└──────────┘└┘└───────────────┘└─
doc     └────┘              └┘           └┘            └┘                 └─
txt     └────┘              └┘           └┘            └┘                 └─
par     └────┘              └┘           └┘            └┘                 └─
pid                       └┘           └┘            └┘                 
st     └─────────────────────────────────────────────────────────────────────
353  
src  
typ  
doc  
txt  
par  
pid  
st   
354  /-- Also known as squeeze or sandwich theorem. -/
355  lemma tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : filter β} {a : α}
id                                                                      └────┘        
src                                                                       └────┘
typ                                                                     └────┘        
356    (hg : tendsto g b (𝓝 a)) (hh : tendsto h b (𝓝 a))
id           └─────┘              └─────┘     
src          └─────┘                 └─────┘      
typ          └─────┘              └─────┘     
doc          └─────┘                 └─────┘      
357    (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) :
id            └┘  └┘               └┘  └┘      
src           └┘   └┘                    └┘   └┘       
typ           └┘  └┘               └┘  └┘      
doc           └┘   └┘                     └┘   └┘  
358    tendsto f b (𝓝 a) :=
id     └─────┘     
src    └─────┘      
typ    └─────┘     
doc    └─────┘      
359  tendsto_order.2
id   └───────────┘
src  └───────────┘
typ  └───────────┘
360    ⟨assume a' h',
id             └┘ └┘
typ            └┘ └┘
361      have ∀ᶠ b in b, a' < g b, from (tendsto_order.1 hg).left a' h',
id            └┘  └┘  └┘           └───────────┘  └┘ └──┘  └┘ └┘
src           └┘   └┘                  └───────────┘     └──┘
typ           └┘  └┘  └┘           └───────────┘  └┘ └──┘  └┘ └┘
doc           └┘   └┘  
362      by filter_upwards [this, hgf] assume a, lt_of_lt_of_le,
id                                               └────────────┘
src         └──────────────┘    └┘   └┘      └──┘└────────────┘
typ         └──────────────┘    └┘   └┘      └──┘└────────────┘
doc         └──────────────┘    └┘   └┘      └──┘
txt         └──────────────┘    └┘   └┘      └──┘
par         └──────────────┘    └┘   └┘      └──┘
pid                       └┘    └┘         └──┘
st         └──────────────────────────────────────────────────┘
363      assume a' h',
id              └┘ └┘
typ             └┘ └┘
364      have ∀ᶠ b in b, h b < a', from (tendsto_order.1 hh).right a' h',
id            └┘  └┘     └┘        └───────────┘  └┘ └───┘  └┘ └┘
src           └┘   └┘                  └───────────┘     └───┘
typ           └┘  └┘     └┘        └───────────┘  └┘ └───┘  └┘ └┘
doc           └┘   └┘  
365      by filter_upwards [this, hfh] assume a h₁ h₂, lt_of_le_of_lt h₂ h₁⟩
id                                                     └────────────┘
src         └──────────────┘    └┘   └┘      └────────┘└────────────┘  
typ         └──────────────┘    └┘   └┘      └────────┘└────────────┘  
doc         └──────────────┘    └┘   └┘      └────────┘                
txt         └──────────────┘    └┘   └┘      └────────┘                
par         └──────────────┘    └┘   └┘      └────────┘                
pid                       └┘    └┘         └────────┘                
st         └──────────────────────────────────────────────────────────────┘
366  
367  lemma nhds_order_unbounded {a : α} (hu : ∃u, a < u) (hl : ∃l, l < a) :
id                                                         
src                                                             
typ                                                        
368    𝓝 a = (⨅l (h₂ : l < a) u (h₂ : a < u), principal (Ioo l u)) :=
id                               └───────┘  └─┘  
src                                     └───────┘  └─┘
typ                              └───────┘  └─┘  
doc                                        └───────┘  └─┘
369  let ⟨u, hu⟩ := hu, ⟨l, hl⟩ := hl in
id   └─┘            └┘      └┘     └┘
typ  └─┘            └┘      └┘     └┘
370  calc 𝓝 a = (⨅b<a, principal {c | b < c}) ⊓ (⨅b>a, principal {c | c < b}) : nhds_eq_order a
id               └───────┘             └───────┘           └───────────┘ 
src                 └───────┘                  └───────┘              └───────────┘
typ              └───────┘             └───────┘           └───────────┘ 
doc                 └───────┘                     └───────┘
371    ... = (⨅b<a, principal {c | b < c} ⊓ (⨅b>a, principal {c | c < b})) :
id              └───────┘            └───────┘      
src               └───────┘                 └───────┘       
typ             └───────┘            └───────┘      
doc               └───────┘                    └───────┘
372      binfi_inf hl
id       └───────┘
src      └───────┘
typ      └───────┘
373    ... = (⨅l<a, (⨅u>a, principal {c | c < u} ⊓ principal {c | l < c})) :
id                 └───────┘         └───────┘      
src                    └───────┘            └───────┘       
typ                └───────┘         └───────┘      
doc                    └───────┘               └───────┘
374      begin
st       └─────
375        congr, funext x,
src        └───┘  └──────┘
typ        └───┘  └──────┘
doc               └──────┘
txt        └───┘  └──────┘
par        └───┘  └──────┘
pid                     └┘
st   ──────────┘└────────┘└─
376        congr, funext hx,
src        └───┘  └───────┘
typ        └───┘  └───────┘
doc               └───────┘
txt        └───┘  └───────┘
par        └───┘  └───────┘
pid                     └─┘
st   ──────────┘└─────────┘└─
377        rw [inf_comm],
id             └──────┘
src        └──┘└──────┘
typ        └──┘└──────┘
doc        └──┘        
txt        └──┘        
par        └──┘        
pid          └┘        
st   ─────────────────┘└──
378        apply binfi_inf hu
id               └───────┘ └┘
src        └────┘└───────┘  
typ        └────┘└───────┘└┘
doc        └────┘           
txt        └────┘           
par        └────┘           
pid                        
st   ─────────────────────────
379      end
src  ───┘
typ  ───┘
doc  ───┘
txt  ───┘
par  ───┘
pid  ───┘
st   ───┘└─┘
380    ... = _ : by simp [inter_comm]; refl
id                        └────────┘
src                 └────┘└────────┘  └────
typ                 └────┘└────────┘  └────
doc                 └────┘            └────
txt                 └────┘            └────
par                 └────┘            └────
pid                                     
st                 └────────────────────────
381  
src  
typ  
doc  
txt  
par  
pid  
st   
382  lemma tendsto_order_unbounded {f : β → α} {a : α} {x : filter β}
id                                                       └────┘ 
src                                                         └────┘
typ                                                      └────┘ 
383    (hu : ∃u, a < u) (hl : ∃l, l < a) (h : ∀l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) :
id                                              └┘  └┘          
src                                                         └┘   └┘               
typ                                             └┘  └┘          
doc                                                                 └┘   └┘  
384    tendsto f x (𝓝 a) :=
id     └─────┘     
src    └─────┘      
typ    └─────┘     
doc    └─────┘      
385  by rw [nhds_order_unbounded hu hl];
id          └──────────────────┘ └┘ └┘
src     └──┘└──────────────────┘    
typ     └──┘└──────────────────┘└┘└┘
doc     └──┘                        
txt     └──┘                        
par     └──┘                        
pid       └┘                        
st     └─────────────────────────────┘└─
386  from (tendsto_infi.2 $ assume l, tendsto_infi.2 $ assume hl,
src  └───┘             └─┘       └──┘            └─┘       └────
typ  └───┘             └─┘       └──┘            └─┘       └────
doc  └───┘             └─┘       └──┘            └─┘       └────
txt  └───┘             └─┘       └──┘            └─┘       └────
par  └───┘             └─┘       └──┘            └─┘       └────
pid  └───┘             └─┘       └──┘            └─┘       └────
st   ─────────────────────────────────────────────────────────────
387    tendsto_infi.2 $ assume u, tendsto_infi.2 $ assume hu, tendsto_principal.2 $ h l u hl hu)
id                                └──────────┘                └───────────────┘     
src  ─┘            └─┘       └──┘└──────────┘└─┘       └───┘└───────────────┘└─┘        └─
typ  ─┘            └─┘       └──┘└──────────┘└─┘       └───┘└───────────────┘└─┘       └─
doc  ─┘            └─┘       └──┘            └─┘       └───┘                 └─┘        └─
txt  ─┘            └─┘       └──┘            └─┘       └───┘                 └─┘        └─
par  ─┘            └─┘       └──┘            └─┘       └───┘                 └─┘        └─
pid  ─┘            └─┘       └──┘            └─┘       └───┘                 └─┘        
st   ────────────────────────────────────────────────────────────────────────────────────────────
388  
src  
typ  
doc  
txt  
par  
pid  
st   
389  end partial_order
390  
391  @[nolint] -- see Note [nolint_ge]
doc    └────┘
392  theorem induced_order_topology' {α : Type u} {β : Type v}
393    [partial_order α] [ta : topological_space β] [partial_order β] [order_topology β]
id      └───────────┘         └───────────────┘    └───────────┘    └────────────┘ 
src     └───────────┘          └───────────────┘     └───────────┘     └────────────┘
typ     └───────────┘         └───────────────┘    └───────────┘    └────────────┘ 
doc                            └───────────────┘                       └────────────┘
394    (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y)
id                                    
src                                           
typ                                   
395    (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b)
id                                
src                                     
typ                               
396    (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) :
id                                
src                                       
typ                               
397    @order_topology _ (induced f ta) _ :=
id      └────────────┘    └─────┘  └┘
src     └────────────┘    └─────┘
typ     └────────────┘    └─────┘  └┘
doc     └────────────┘    └─────┘
398  begin
st   └─────
399    letI := induced f ta,
id             └─────┘  └┘
src    └──────┘└─────┘ 
typ    └──────┘└─────┘└┘
doc    └──────┘└─────┘ 
txt    └──────┘        
par    └──────┘        
pid        └─┘        
st   ─────────────────────┘└─
400    refine ⟨eq_of_nhds_eq_nhds (λ a, _)⟩,
id             └────────────────┘
src    └─────┘ └────────────────┘  └─────┘
typ    └─────┘ └────────────────┘  └─────┘
doc    └─────┘                     └─────┘
txt    └─────┘                     └─────┘
par    └─────┘                     └─────┘
pid                               └─────┘
st   ─────────────────────────────────────┘└─
401    rw [nhds_induced, nhds_generate_from, nhds_eq_order (f a)],
id         └──────────┘  └────────────────┘  └───────────┘   
src    └──┘└──────────┘└┘└────────────────┘└┘└───────────┘   └┘
typ    └──┘└──────────┘└┘└────────────────┘└┘└───────────┘ └┘
doc    └──┘            └┘                  └┘                └┘
txt    └──┘            └┘                  └┘                └┘
par    └──┘            └┘                  └┘                └┘
pid      └┘            └┘                  └┘                └┘
st   ─────────────────┘└──────────────────┘└───────────────────┘└──
402    apply le_antisymm,
id           └─────────┘
src    └────┘└─────────┘
typ    └────┘└─────────┘
doc    └────┘
txt    └────┘
par    └────┘
pid         
st   ──────────────────┘└─
403    { refine le_infi (λ s, le_infi $ λ hs, le_principal_iff.2 _),
id                            └─────┘         └──────────────┘
src      └─────┘         └──┘└─────┘  └───┘└──────────────┘└───┘
typ      └─────┘         └──┘└─────┘  └───┘└──────────────┘└───┘
doc      └─────┘         └──┘         └───┘                └───┘
txt      └─────┘         └──┘         └───┘                └───┘
par      └─────┘         └──┘         └───┘                └───┘
pid                     └──┘         └───┘                └───┘
st   ───┘└────────────────────────────────────────────────────────┘└─
404      rcases hs with ⟨ab, b, rfl|rfl⟩,
id              └┘
src      └─────┘  └────────────────────┘
typ      └─────┘└┘└────────────────────┘
doc      └─────┘  └────────────────────┘
txt      └─────┘  └────────────────────┘
par      └─────┘  └────────────────────┘
pid              └────────────────────┘
st   ──────────────────────────────────┘└─
405      { exact mem_comap_sets.2 ⟨{x | f b < x},
id               └────────────┘          
src        └────┘└────────────┘└─┘ └──┘   └──
typ        └────┘└────────────┘└─┘ └──┘ └──
doc        └────┘              └─┘  └──┘    └──
txt        └────┘              └─┘  └──┘    └──
par        └────┘              └─┘  └──┘    └──
pid                           └─┘  └──┘    └──
st   ─────┘└──────────────────────────────────────
406          mem_inf_sets_of_left $ mem_infi_sets _ $ mem_infi_sets (hf.2 ab) $ mem_principal_self _,
id           └──────────────────┘                     └───────────┘       └┘    └────────────────┘
src  ───────┘└──────────────────┘              └─┘ └───────────┘   └─┘  └┘ └────────────────┘└───
typ  ───────┘└──────────────────┘              └─┘ └───────────┘   └─┘└┘└┘ └────────────────┘└───
doc  ───────┘                                  └─┘                 └─┘  └┘                   └───
txt  ───────┘                                  └─┘                 └─┘  └┘                   └───
par  ───────┘                                  └─┘                 └─┘  └┘                   └───
pid  ───────┘                                  └─┘                 └─┘  └┘                   └───
st   ─────────────────────────────────────────────────────────────────────────────────────────────────
407          λ x, hf.1⟩ },
id                └┘
src  ───────┘ └──┘  └──┘
typ  ───────┘ └──┘└┘└──┘
doc  ───────┘ └──┘  └──┘
txt  ───────┘ └──┘  └──┘
par  ───────┘ └──┘  └──┘
pid  ───────┘ └──┘  └─┘
st   ──────────────────┘└┘
408      { exact mem_comap_sets.2 ⟨{x | x < f b},
id               └────────────┘              
src        └────┘└────────────┘└─┘  └──┘    └──
typ        └────┘└────────────┘└─┘  └──┘  └──
doc        └────┘              └─┘  └──┘    └──
txt        └────┘              └─┘  └──┘    └──
par        └────┘              └─┘  └──┘    └──
pid                           └─┘  └──┘    └──
st   ─────────────────────────────────────────────
409          mem_inf_sets_of_right $ mem_infi_sets _ $ mem_infi_sets (hf.2 ab) $ mem_principal_self _,
id           └───────────────────┘                     └───────────┘       └┘    └────────────────┘
src  ───────┘└───────────────────┘              └─┘ └───────────┘   └─┘  └┘ └────────────────┘└───
typ  ───────┘└───────────────────┘              └─┘ └───────────┘   └─┘└┘└┘ └────────────────┘└───
doc  ───────┘                                   └─┘                 └─┘  └┘                   └───
txt  ───────┘                                   └─┘                 └─┘  └┘                   └───
par  ───────┘                                   └─┘                 └─┘  └┘                   └───
pid  ───────┘                                   └─┘                 └─┘  └┘                   └───
st   ──────────────────────────────────────────────────────────────────────────────────────────────────
410          λ x, hf.1⟩ } },
id                └┘
src  ───────┘ └──┘  └──┘
typ  ───────┘ └──┘└┘└──┘
doc  ───────┘ └──┘  └──┘
txt  ───────┘ └──┘  └──┘
par  ───────┘ └──┘  └──┘
pid  ───────┘ └──┘  └─┘
st   ──────────────────┘└──┘
411    { rw [← map_le_iff_le_comap],
id             └─────────────────┘
src      └────┘└─────────────────┘
typ      └────┘└─────────────────┘
doc      └────┘                   
txt      └────┘                   
par      └────┘                   
pid        └──┘                   
st   ────────────────────────────┘└──
412      refine le_inf _ _; refine le_infi (λ x, le_infi $ λ h, le_principal_iff.2 _); simp,
id              └────┘                           └─────┘        └──────────────┘
src      └─────┘└────┘└──┘  └─────┘         └──┘└─────┘  └──┘└──────────────┘└───┘  └──┘
typ      └─────┘└────┘└──┘  └─────┘         └──┘└─────┘  └──┘└──────────────┘└───┘  └──┘
doc      └─────┘      └──┘  └─────┘         └──┘         └──┘                └───┘  └──┘
txt      └─────┘      └──┘  └─────┘         └──┘         └──┘                └───┘  └──┘
par      └─────┘      └──┘  └─────┘         └──┘         └──┘                └───┘  └──┘
pid                  └──┘                 └──┘         └──┘                └───┘
st   ─────────────────────────────────────────────────────────────────────────────────────┘└─
413      { rcases H₁ h with ⟨b, ab, xb⟩,
id                └┘ 
src        └─────┘   └───────────────┘
typ        └─────┘└┘└───────────────┘
doc        └─────┘   └───────────────┘
txt        └─────┘   └───────────────┘
par        └─────┘   └───────────────┘
pid                 └───────────────┘
st   ─────┘└──────────────────────────┘└─
414        refine mem_infi_sets _ (mem_infi_sets ⟨ab, b, or.inl rfl⟩ (mem_principal_sets.2 _)),
id                                 └───────────┘  └┘    └────┘ └─┘   └────────────────┘
src        └─────┘             └─┘ └───────────┘   └┘ └┘└────┘└─┘└┘ └────────────────┘└────┘
typ        └─────┘             └─┘ └───────────┘ └┘└┘└┘└────┘└─┘└┘ └────────────────┘└────┘
doc        └─────┘             └─┘                 └┘ └┘         └┘                   └────┘
txt        └─────┘             └─┘                 └┘ └┘         └┘                   └────┘
par        └─────┘             └─┘                 └┘ └┘         └┘                   └────┘
pid                           └─┘                 └┘ └┘         └┘                   └────┘
st   ────────────────────────────────────────────────────────────────────────────────────────┘└─
415        exact λ c hc, lt_of_le_of_lt xb (hf.2 hc) },
id                       └────────────┘ └┘  └┘
src        └────┘ └─────┘└────────────┘     └─┘  └┘
typ        └────┘ └─────┘└────────────┘└┘ └┘└─┘  └┘
doc        └────┘ └─────┘                   └─┘  └┘
txt        └────┘ └─────┘                   └─┘  └┘
par        └────┘ └─────┘                   └─┘  └┘
pid              └─────┘                   └─┘  
st   ───────────────────────────────────────────────┘└┘
416      { rcases H₂ h with ⟨b, ab, xb⟩,
id                └┘ 
src        └─────┘   └───────────────┘
typ        └─────┘└┘└───────────────┘
doc        └─────┘   └───────────────┘
txt        └─────┘   └───────────────┘
par        └─────┘   └───────────────┘
pid                 └───────────────┘
st   ─────────────────────────────────┘└─
417        refine mem_infi_sets _ (mem_infi_sets ⟨ab, b, or.inr rfl⟩ (mem_principal_sets.2 _)),
id                                 └───────────┘  └┘    └────┘ └─┘   └────────────────┘
src        └─────┘             └─┘ └───────────┘   └┘ └┘└────┘└─┘└┘ └────────────────┘└────┘
typ        └─────┘             └─┘ └───────────┘ └┘└┘└┘└────┘└─┘└┘ └────────────────┘└────┘
doc        └─────┘             └─┘                 └┘ └┘         └┘                   └────┘
txt        └─────┘             └─┘                 └┘ └┘         └┘                   └────┘
par        └─────┘             └─┘                 └┘ └┘         └┘                   └────┘
pid                           └─┘                 └┘ └┘         └┘                   └────┘
st   ────────────────────────────────────────────────────────────────────────────────────────┘└─
418        exact λ c hc, lt_of_lt_of_le (hf.2 hc) xb } },
id                       └────────────┘  └┘       └┘
src        └────┘ └─────┘└────────────┘   └─┘  └┘  
typ        └────┘ └─────┘└────────────┘ └┘└─┘  └┘└┘
doc        └────┘ └─────┘                 └─┘  └┘  
txt        └────┘ └─────┘                 └─┘  └┘  
par        └────┘ └─────┘                 └─┘  └┘  
pid              └─────┘                 └─┘  └┘  
st   ───────────────────────────────────────────────┘└────
419  end
st   ──┘
420  
421  theorem induced_order_topology {α : Type u} {β : Type v}
422    [partial_order α] [ta : topological_space β] [partial_order β] [order_topology β]
id      └───────────┘         └───────────────┘    └───────────┘    └────────────┘ 
src     └───────────┘          └───────────────┘     └───────────┘     └────────────┘
typ     └───────────┘         └───────────────┘    └───────────┘    └────────────┘ 
doc                            └───────────────┘                       └────────────┘
423    (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y)
id                                    
src                                           
typ                                   
424    (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) :
id                                
src                                        
typ                               
425    @order_topology _ (induced f ta) _ :=
id      └────────────┘    └─────┘  └┘
src     └────────────┘    └─────┘
typ     └────────────┘    └─────┘  └┘
doc     └────────────┘    └─────┘
426  induced_order_topology' f @hf
id   └─────────────────────┘   └┘
src  └─────────────────────┘
typ  └─────────────────────┘   └┘
427    (λ a x xa, let ⟨b, xb, ba⟩ := H xa in ⟨b, hf.1 ba, le_of_lt xb⟩)
id          └┘  └─┘    └┘  └┘      └┘        └┘      └──────┘
src                                                      └──────┘
typ         └┘  └─┘    └┘  └┘      └┘        └┘      └──────┘
428    (λ a x ax, let ⟨b, ab, bx⟩ := H ax in ⟨b, hf.1 ab, le_of_lt bx⟩)
id          └┘  └─┘    └┘  └┘      └┘        └┘      └──────┘
src                                                      └──────┘
typ         └┘  └─┘    └┘  └┘      └┘        └┘      └──────┘
429  
430  lemma nhds_top_order [topological_space α] [order_top α] [order_topology α] :
id                         └───────────────┘    └───────┘    └────────────┘ 
src                        └───────────────┘     └───────┘     └────────────┘
typ                        └───────────────┘    └───────┘    └────────────┘ 
doc                        └───────────────┘     └───────┘     └────────────┘
431    𝓝 (⊤:α) = (⨅l (h₂ : l < ⊤), principal (Ioi l)) :=
id                       └───────┘  └─┘ 
src                         └───────┘  └─┘
typ                      └───────┘  └─┘ 
doc                             └───────┘  └─┘
432  by simp [nhds_eq_order (⊤:α)]
id            └───────────┘   
src     └────┘└───────────┘  └──
typ     └────┘└───────────┘ └──
doc     └────┘                └──
txt     └────┘                └──
par     └────┘                └──
pid                         └┘
st     └───────────────────────────
433  
src  
typ  
doc  
txt  
par  
pid  
st   
434  lemma nhds_bot_order [topological_space α] [order_bot α] [order_topology α] :
id                         └───────────────┘    └───────┘    └────────────┘ 
src                        └───────────────┘     └───────┘     └────────────┘
typ                        └───────────────┘    └───────┘    └────────────┘ 
doc                        └───────────────┘     └───────┘     └────────────┘
435    𝓝 (⊥:α) = (⨅l (h₂ : ⊥ < l), principal (Iio l)) :=
id                       └───────┘  └─┘ 
src                         └───────┘  └─┘
typ                      └───────┘  └─┘ 
doc                             └───────┘  └─┘
436  by simp [nhds_eq_order (⊥:α)]
id            └───────────┘   
src     └────┘└───────────┘  └──
typ     └────┘└───────────┘ └──
doc     └────┘                └──
txt     └────┘                └──
par     └────┘                └──
pid                         └┘
st     └───────────────────────────
437  
src  
typ  
doc  
txt  
par  
pid  
st   
438  section linear_order
439  
440  variables [topological_space α] [linear_order α] [order_topology α]
id              └───────────────┘     └──────────┘     └────────────┘
src             └───────────────┘     └──────────┘     └────────────┘
typ             └───────────────┘     └──────────┘     └────────────┘
doc             └───────────────┘                      └────────────┘
441  
442  lemma exists_Ioc_subset_of_mem_nhds' {a : α} {s : set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) :
id                                                    └─┘                             
src                                                    └─┘                                 
typ                                                   └─┘                             
doc                                                                     
443    ∃ l' ∈ Ico l a, Ioc l' a ⊆ s :=
id      └┘   └─┘   └─┘ └┘   
src          └─┘     └─┘      
typ     └┘   └─┘   └─┘ └┘   
doc           └─┘      └─┘
444  begin
st   └─────
445    rw [nhds_eq_order a] at hs,
id         └───────────┘ 
src    └──┘└───────────┘ └─────┘
typ    └──┘└───────────┘└─────┘
doc    └──┘              └─────┘
txt    └──┘              └─────┘
par    └──┘              └─────┘
pid      └┘              └────┘
st   ────────────────────┘└────┘└─
446    rcases hs with ⟨t₁, ht₁, t₂, ht₂, hts⟩,
id            └┘
src    └─────┘  └───────────────────────────┘
typ    └─────┘└┘└───────────────────────────┘
doc    └─────┘  └───────────────────────────┘
txt    └─────┘  └───────────────────────────┘
par    └─────┘  └───────────────────────────┘
pid            └───────────────────────────┘
st   ───────────────────────────────────────┘└─
447    -- First we show that `t₂` includes `(-∞, a]`, so it suffices to show `(l', ∞) ⊆ t₁`
st   ───────────────────────────────────────────────────────────────────────────────────────
448    suffices : ∃ l' ∈ Ico l a, Ioi l' ⊆ t₁,
id                      └─┘   └─┘     └┘
src    └─────────┘└────┘└─┘  └─┘  
typ    └─────────┘└────┘└─┘└─┘  └┘
doc    └─────────┘ └────┘└─┘   └─┘   
txt    └─────────┘ └────┘            
par    └─────────┘ └────┘            
pid    └───────┘└┘ └────┘            
st   ───────────────────────────────────────┘└─
449    { have A : principal (Iic a) ≤ ⨅ b ∈ Ioi a, principal (Iio b),
id                           └─┘          └─┘  └───────┘  └─┘
src      └───────┘          └─┘ └┘└───┘└─┘ └───────┘ └─┘ 
typ      └───────┘          └─┘ └┘└───┘└─┘└───────┘ └─┘ 
doc      └───────┘          └─┘ └┘ └───┘└─┘ └───────┘ └─┘ 
txt      └───────┘              └┘  └───┘                   
par      └───────┘              └┘  └───┘                   
pid      └────┘└─┘              └┘  └───┘                   
st   ───┘└─────────────────────────────────────────────────────────┘└─
450        from (le_infi $ λ b, le_infi $ λ hb, principal_mono.2 $ Iic_subset_Iio.2 hb),
id                              └─────┘         └────────────┘     └────────────┘
src        └───┘          └──┘└─────┘  └───┘└────────────┘└─┘ └────────────┘└─┘  
typ        └───┘          └──┘└─────┘  └───┘└────────────┘└─┘ └────────────┘└─┘  
doc        └───┘          └──┘         └───┘              └─┘               └─┘  
txt        └───┘          └──┘         └───┘              └─┘               └─┘  
par        └───┘          └──┘         └───┘              └─┘               └─┘  
pid        └───┘          └──┘         └───┘              └─┘               └─┘  
st   ─────────────────────────────────────────────────────────────────────────────────┘└─
451      have B : t₁ ∩ Iic a ⊆ s,
id                └┘  └─┘    
src      └───────┘  └─┘  
typ      └───────┘└┘└─┘ 
doc      └───────┘   └─┘  
txt      └───────┘        
par      └───────┘        
pid      └────┘└─┘        
st   ──────────────────────────┘└─
452        from subset.trans (inter_subset_inter_right _ (A ht₂)) hts,
id              └──────────┘  └──────────────────────┘     └─┘   └─┘
src        └───┘└──────────┘ └──────────────────────┘└─┘     └─┘
typ        └───┘└──────────┘ └──────────────────────┘└─┘ └─┘└─┘└─┘
doc        └───┘                                     └─┘     └─┘
txt        └───┘                                     └─┘     └─┘
par        └───┘                                     └─┘     └─┘
pid        └───┘                                     └─┘     └─┘
st   ───────────────────────────────────────────────────────────────┘└─
453      from this.imp (λ l', Exists.imp $ λ hl' hl x hx, B ⟨hl hx.1, hx.2⟩) },
id            └──────┘        └────────┘                  
src      └───┘└──────┘  └───┘└────────┘  └────────────┘      └──┘  └───┘
typ      └───┘└──────┘  └───┘└────────┘  └────────────┘     └──┘  └───┘
doc      └───┘          └───┘            └────────────┘      └──┘  └───┘
txt      └───┘          └───┘            └────────────┘      └──┘  └───┘
par      └───┘          └───┘            └────────────┘      └──┘  └───┘
pid      └───┘          └───┘            └────────────┘      └──┘  └──┘
st   ───────────────────────────────────────────────────────────────────────┘└┘
454    clear hts ht₂ t₂,
src    └──────────────┘
typ    └──────────────┘
doc    └──────────────┘
txt    └──────────────┘
par    └──────────────┘
pid         └─────────┘
st   ─────────────────┘└─
455    -- Now we find `l` such that `(l', ∞) ⊆ t₁`
st   ──────────────────────────────────────────────
456    letI := classical.DLO α,
id             └───────────┘ 
src    └──────┘└───────────┘
typ    └──────┘└───────────┘
doc    └──────┘             
txt    └──────┘             
par    └──────┘             
pid        └─┘             
st   ────────────────────────┘└─
457    rw [mem_binfi] at ht₁,
id         └───────┘
src    └──┘└───────┘└──────┘
typ    └──┘└───────┘└──────┘
doc    └──┘         └──────┘
txt    └──┘         └──────┘
par    └──┘         └──────┘
pid      └┘         └─────┘
st   ──────────────┘└─────┘└─
458    { rcases ht₁ with ⟨b, hb, hb'⟩,
id              └─┘
src      └─────┘   └────────────────┘
typ      └─────┘└─┘└────────────────┘
doc      └─────┘   └────────────────┘
txt      └─────┘   └────────────────┘
par      └─────┘   └────────────────┘
pid               └────────────────┘
st   ───┘└──────────────────────────┘└─
459      exact ⟨max b l, ⟨le_max_right _ _, max_lt hb hl⟩,
id              └─┘     └──────────┘      └────┘ └┘ └┘
src      └────┘ └─┘  └┘ └──────────┘└────┘└────┘    └──
typ      └────┘ └─┘└┘ └──────────┘└────┘└────┘└┘└┘└──
doc      └────┘      └┘             └────┘          └──
txt      └────┘      └┘             └────┘          └──
par      └────┘      └┘             └────┘          └──
pid                 └┘             └────┘          └──
st   ──────────────────────────────────────────────────────
460        λ x hx, hb' $ Ioi_subset_Ioi (le_max_left _ _) hx⟩ },
id                 └─┘   └────────────┘  └─────────┘
src  ─────┘ └─────┘    └────────────┘ └─────────┘└────┘  └┘
typ  ─────┘ └─────┘└─┘ └────────────┘ └─────────┘└────┘  └┘
doc  ─────┘ └─────┘    └────────────┘            └────┘  └┘
txt  ─────┘ └─────┘                              └────┘  └┘
par  ─────┘ └─────┘                              └────┘  └┘
pid  ─────┘ └─────┘                              └────┘  
st   ────────────────────────────────────────────────────────┘└┘
461    { intros b hb b' hb', simp only [mem_Iio] at hb hb',
id                                      └─────┘
src      └────────────────┘  └─────────┘└─────┘└─────────┘
typ      └────────────────┘  └─────────┘└─────┘└─────────┘
doc      └────────────────┘  └─────────┘       └─────────┘
txt      └────────────────┘  └─────────┘       └─────────┘
par      └────────────────┘  └─────────┘       └─────────┘
pid            └──────────┘      └──┘└┘       └───────┘
st   ───┘└────────────────┘└─────────────────────────────┘└─
462      use [max b b', max_lt hb hb'],
id            └─┘  └┘  └────┘ └┘ └─┘
src      └───┘└─┘   └┘└────┘     
typ      └───┘└─┘└┘└┘└────┘└┘└─┘
doc      └───┘      └┘           
txt      └───┘      └┘           
par      └───┘      └┘           
pid         └┘      └┘           
st   ────────────────────────────────┘└─
463      simp [le_refl] },
id             └─────┘
src      └────┘└─────┘└┘
typ      └────┘└─────┘└┘
doc      └────┘       └┘
txt      └────┘       └┘
par      └────┘       └┘
pid                 
st   ──────────────────┘└┘
464    exact ⟨l, hl⟩
id              └┘
src    └────┘  └┘  └┘
typ    └────┘ └┘└┘└┘
doc    └────┘  └┘  └┘
txt    └────┘  └┘  └┘
par    └────┘  └┘  └┘
pid           └┘  
st   ───────────────┘
465  end
st   └─┘
466  
467  lemma exists_Ico_subset_of_mem_nhds' {a : α} {s : set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) :
id                                                    └─┘                             
src                                                    └─┘                                 
typ                                                   └─┘                             
doc                                                                     
468    ∃ u' ∈ Ioc a u, Ico a u' ⊆ s :=
id      └┘   └─┘   └─┘  └┘  
src          └─┘     └─┘      
typ     └┘   └─┘   └─┘  └┘  
doc           └─┘      └─┘
469  begin
st   └─────
470    convert @exists_Ioc_subset_of_mem_nhds' (order_dual α) _ _ _ _ _ hs _ hu,
id              └────────────────────────────┘  └────────┘             └┘   └┘
src    └──────┘ └────────────────────────────┘ └────────┘ └──────────┘  └─┘
typ    └──────┘ └────────────────────────────┘ └────────┘└──────────┘└┘└─┘└┘
doc    └──────┘                                └────────┘ └──────────┘  └─┘
txt    └──────┘                                           └──────────┘  └─┘
par    └──────┘                                           └──────────┘  └─┘
pid                                                      └──────────┘  └─┘
st   ─────────────────────────────────────────────────────────────────────────┘└─
471    ext, rw [dual_Ico, dual_Ioc]
id              └──────┘  └──────┘
src    └─┘  └──┘└──────┘└┘└──────┘└┘
typ    └─┘  └──┘└──────┘└┘└──────┘└┘
doc    └─┘  └──┘        └┘        └┘
txt    └─┘  └──┘        └┘        └┘
par    └─┘  └──┘        └┘        └┘
pid           └┘        └┘        
st   ────┘└────────────┘└────────┘
472  end
st   └─┘
473  
474  lemma exists_Ioc_subset_of_mem_nhds {a : α} {s : set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) :
id                                                   └─┘                       
src                                                   └─┘                           
typ                                                  └─┘                       
doc                                                                    
475    ∃ l < a, Ioc l a ⊆ s :=
id          └─┘    
src           └─┘     
typ         └─┘    
doc             └─┘
476  let ⟨l', hl'⟩ := h in let ⟨l, hl⟩ := exists_Ioc_subset_of_mem_nhds' hs hl' in ⟨l, hl.fst.2, hl.snd⟩
id   └─┘      └─┘         └─┘    └┘     └────────────────────────────┘ └┘              └──┘     └──┘
src                                       └────────────────────────────┘                 └──┘     └──┘
typ  └─┘      └─┘         └─┘    └┘     └────────────────────────────┘ └┘              └──┘     └──┘
477  
478  lemma exists_Ico_subset_of_mem_nhds {a : α} {s : set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) :
id                                                   └─┘                       
src                                                   └─┘                           
typ                                                  └─┘                       
doc                                                                    
479    ∃ u (_ : a < u), Ico a u ⊆ s :=
id                └─┘    
src                  └─┘     
typ               └─┘    
doc                     └─┘
480  let ⟨l', hl'⟩ := h in let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' in ⟨l, hl.fst.1, hl.snd⟩
id   └─┘      └─┘         └─┘    └┘     └────────────────────────────┘ └┘              └──┘     └──┘
src                                       └────────────────────────────┘                 └──┘     └──┘
typ  └─┘      └─┘         └─┘    └┘     └────────────────────────────┘ └┘              └──┘     └──┘
481  
482  lemma mem_nhds_unbounded {a : α} {s : set α} (hu : ∃u, a < u) (hl : ∃l, l < a) :
id                                        └─┘                       
src                                        └─┘                            
typ                                       └─┘                       
483    s ∈ 𝓝 a ↔ (∃l u, l < a ∧ a < u ∧ ∀b, l < b → b < u → b ∈ s) :=
id                                    
src                                                
typ                                   
doc        
484  let ⟨l, hl'⟩ := hl, ⟨u, hu'⟩ := hu in
id   └─┘             └┘              └┘
typ  └─┘             └┘              └┘
485  have 𝓝 a = (⨅p : {l // l < a} × {u // a < u}, principal (Ioo p.1.val p.2.val)),
id                                 └───────┘  └─┘  └─┘   └─┘
src                                       └───────┘  └─┘   └─┘    └─┘
typ                                └───────┘  └─┘  └─┘   └─┘
doc                                             └───────┘  └─┘
486    by simp [nhds_order_unbounded hu hl, infi_subtype, infi_prod],
id              └──────────────────┘ └┘ └┘  └──────────┘  └───────┘
src       └────┘└──────────────────┘    └┘└──────────┘└┘└───────┘
typ       └────┘└──────────────────┘└┘└┘└┘└──────────┘└┘└───────┘
doc       └────┘                        └┘            └┘         
txt       └────┘                        └┘            └┘         
par       └────┘                        └┘            └┘         
pid                                   └┘            └┘         
st       └─────────────────────────────────────────────────────────┘
487  iff.intro
id   └───────┘
src  └───────┘
typ  └───────┘
488    (assume hs, by rw [this] at hs; from infi_sets_induct hs
id             └┘         └──┘              └──────────────┘ └┘
src                   └──┘    └─────┘  └───┘└──────────────┘  
typ            └┘     └──┘└──┘└─────┘  └───┘└──────────────┘└┘
doc                   └──┘    └─────┘  └───┘                  
txt                   └──┘    └─────┘  └───┘                  
par                   └──┘    └─────┘  └───┘                  
pid                     └┘    └────┘  └───┘                  
st                   └───────┘└────────────────────────────────
489      ⟨l, u, hl', hu', by simp⟩
id            └─┘  └─┘
src  ───┘  └┘ └┘   └┘   └┘  └──┘└─
typ  ───┘ └┘└┘└─┘└┘└─┘└┘  └──┘└─
doc  ───┘  └┘ └┘   └┘   └┘  └──┘└─
txt  ───┘  └┘ └┘   └┘   └┘  └──┘└─
par  ───┘  └┘ └┘   └┘   └┘  └──┘└─
pid  ───┘  └┘ └┘   └┘   └┘  └──────
st   ──────────────────────┘└───┘└─
490      begin
src  ───┘     
typ  ───┘     
doc  ───┘     
txt  ───┘     
par  ───┘     
pid  ───┘     
st   ───┘└─────
491        intro p, rcases p with ⟨⟨l, hl⟩, ⟨u, hu⟩⟩,
id                         
src  ─────┘└─────┘└┘└─────┘ └──────────────────────┘└─
typ  ─────┘└─────┘└┘└─────┘└──────────────────────┘└─
doc  ─────┘└─────┘└┘└─────┘ └──────────────────────┘└─
txt  ─────┘└─────┘└┘└─────┘ └──────────────────────┘└─
par  ─────┘└─────┘└┘└─────┘ └──────────────────────┘└─
pid  ─────────────────────┘ └─────────────────────────
st   ────────────┘└────────────────────────────────┘└─
492        simp [set.subset_def],
id               └────────────┘
src  ─────┘└────┘└────────────┘└─
typ  ─────┘└────┘└────────────┘└─
doc  ─────┘└────┘              └─
txt  ─────┘└────┘              └─
par  ─────┘└────┘              └─
pid  ───────────┘              └──
st   ──────────────────────────┘└─
493        intros s₁ s₂ hs₁ l' hl' u' hu' hs₂,
src  ─────┘└────────────────────────────────┘└─
typ  ─────┘└────────────────────────────────┘└─
doc  ─────┘└────────────────────────────────┘└─
txt  ─────┘└────────────────────────────────┘└─
par  ─────┘└────────────────────────────────┘└─
pid  ──────────────────────────────────────────
st   ───────────────────────────────────────┘└─
494        letI := classical.DLO α,
id                 └───────────┘ 
src  ─────┘└──────┘└───────────┘ └─
typ  ─────┘└──────┘└───────────┘└─
doc  ─────┘└──────┘              └─
txt  ─────┘└──────┘              └─
par  ─────┘└──────┘              └─
pid  ─────────────┘              └─
st   ────────────────────────────┘└─
495        refine ⟨max l l', _, min u u', _⟩;
id                 └─┘  └┘     └─┘  └┘
src  ─────┘└─────┘ └─┘   └───┘└─┘   └──┘└─
typ  ────────────┘ └─┘└┘└───┘└─┘└┘└─────
doc  ─────┘└─────┘       └───┘      └──┘└─
txt  ─────┘└─────┘       └───┘      └──┘└─
par  ────────────┘       └───┘      └─────
pid  ────────────┘       └───┘      └─────
st   ─────────────────────────────────────────
496        simp [*, lt_min_iff, max_lt_iff] {contextual := tt}
id                  └────────┘  └────────┘                 └┘
src  ─────┘└───────┘└────────┘└┘└────────┘└┘ └────────────┘└┘└─
typ  ─────┘└───────┘└────────┘└┘└────────┘└┘ └────────────┘└┘└─
doc  ─────┘└───────┘          └┘          └┘ └────────────┘  └─
txt  ─────┘└───────┘          └┘          └┘ └────────────┘  └─
par  ─────┘└───────┘          └┘          └┘ └────────────┘  └─
pid  ──────────────┘          └┘          └┘ └────────────┘  └─
st   ──────────────────────────────────────────────────────────
497      end
src  ───┘└───
typ  ───┘└───
doc  ───┘└───
txt  ───┘└───
par  ───┘└───
pid  ────────
st   ───┘└─┘
498      (assume s₁ s₂ h ⟨l, u, h₁, h₂, h₃⟩, ⟨l, u, h₁, h₂, assume b hu hl, h $ h₃ _ hu hl⟩))
id                            └┘  └┘  └┘
src  ───┘       └────────┘ └┘ └┘  └┘  └┘  └─┘  └┘ └┘  └┘  └┘      └────────┘    └─┘    └┘
typ  ───┘       └────────┘└┘└┘└┘└┘└┘└┘└┘└─┘  └┘ └┘  └┘  └┘      └────────┘    └─┘    └┘
doc  ───┘       └────────┘ └┘ └┘  └┘  └┘  └─┘  └┘ └┘  └┘  └┘      └────────┘    └─┘    └┘
txt  ───┘       └────────┘ └┘ └┘  └┘  └┘  └─┘  └┘ └┘  └┘  └┘      └────────┘    └─┘    └┘
par  ───┘       └────────┘ └┘ └┘  └┘  └┘  └─┘  └┘ └┘  └┘  └┘      └────────┘    └─┘    └┘
pid  ───┘       └────────┘ └┘ └┘  └┘  └┘  └─┘  └┘ └┘  └┘  └┘      └────────┘    └─┘    └┘
st   ──────────────────────────────────────────────────────────────────────────────────────┘
499    (assume ⟨l, u, hl, hu, h⟩,
id             
typ            
500      by rw [this]; exact mem_infi_sets ⟨⟨l, hl⟩, ⟨u, hu⟩⟩ (assume b ⟨h₁, h₂⟩, h b h₁ h₂))
id              └──┘         └───────────┘     └┘      └┘              └┘  └┘   
src         └──┘      └────┘└───────────┘   └┘  └─┘  └┘  └─┘       └──┘  └┘  └─┘      
typ         └──┘└──┘  └────┘└───────────┘  └┘└┘└─┘ └┘└┘└─┘       └──┘└┘└┘└┘└─┘     
doc         └──┘      └────┘                └┘  └─┘  └┘  └─┘       └──┘  └┘  └─┘      
txt         └──┘      └────┘                └┘  └─┘  └┘  └─┘       └──┘  └┘  └─┘      
par         └──┘      └────┘                └┘  └─┘  └┘  └─┘       └──┘  └┘  └─┘      
pid           └┘                           └┘  └─┘  └┘  └─┘       └──┘  └┘  └─┘      
st         └───────┘└─────────────────────────────────────────────────────────────────────┘
501  
502  lemma order_separated {a₁ a₂ : α} (h : a₁ < a₂) :
id                                         └┘  └┘
src                                            
typ                                        └┘  └┘
503    ∃u v : set α, is_open u ∧ is_open v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ (∀b₁∈u, ∀b₂∈v, b₁ < b₂) :=
id           └─┘  └─────┘   └─────┘   └┘    └┘      └┘    └┘   └┘  └┘
src          └─┘   └─────┘    └─────┘                                    
typ          └─┘  └─────┘   └─────┘   └┘    └┘      └┘    └┘   └┘  └┘
doc                  └─────┘     └─────┘
504  match dense_or_discrete a₁ a₂ with
id         └───────────────┘ └┘ └┘
src        └───────────────┘
typ        └───────────────┘ └┘ └┘
505  | or.inl ⟨a, ha₁, ha₂⟩ := ⟨{a' | a' < a}, {a' | a < a'}, is_open_gt' a, is_open_lt' a, ha₁, ha₂,
id     └────┘    └─┘  └─┘      └┘   └┘      └┘      └┘   └─────────┘    └─────────┘
src    └────┘                                             └─────────┘    └─────────┘
typ    └────┘    └─┘  └─┘      └┘   └┘      └┘      └┘   └─────────┘    └─────────┘
506      assume b₁ h₁ b₂ h₂, lt_trans h₁ h₂⟩
id              └┘ └┘ └┘ └┘  └──────┘ └┘ └┘
src                          └──────┘
typ             └┘ └┘ └┘ └┘  └──────┘ └┘ └┘
507  | or.inr ⟨h₁, h₂⟩ := ⟨{a | a < a₂}, {a | a₁ < a}, is_open_gt' a₂, is_open_lt' a₁, h, h,
id     └────┘  └┘  └┘           └┘      └┘     └─────────┘ └┘  └─────────┘ └┘    
src    └────┘                                      └─────────┘     └─────────┘
typ    └────┘  └┘  └┘           └┘      └┘     └─────────┘ └┘  └─────────┘ └┘    
508      assume b₁ hb₁ b₂ hb₂,
id              └┘ └─┘ └┘ └─┘
typ             └┘ └─┘ └┘ └─┘
509      calc b₁ ≤ a₁ : h₂ _ hb₁
id            └┘   └┘        └─┘
typ           └┘   └┘        └─┘
510        ... < a₂ : h
id               └┘   
typ              └┘   
511        ... ≤ b₂ : h₁ _ hb₂⟩
id               └┘        └─┘
typ              └┘        └─┘
512  end
513  
514  @[priority 100] -- see Note [lower instance priority]
515  instance order_topology.to_order_closed_topology : order_closed_topology α :=
id                                                      └───────────────────┘ 
src                                                     └───────────────────┘
typ                                                     └───────────────────┘ 
doc                                                     └───────────────────┘
516  { is_closed_le' :=
517      is_open_prod_iff.mpr $ assume a₁ a₂ (h : ¬ a₁ ≤ a₂),
id       └──────────────┘└──┘          └┘ └┘       └┘  └┘
src      └──────────────┘└──┘                         
typ      └──────────────┘└──┘          └┘ └┘       └┘  └┘
518        have h : a₂ < a₁, from lt_of_not_ge h,
id                  └┘  └┘       └──────────┘ 
src                              └──────────┘
typ                 └┘  └┘       └──────────┘ 
519        let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h in
id         └─┘      └┘  └┘  └─┘  └─┘       └─────────────┘ 
src                                           └─────────────┘
typ        └─┘      └┘  └┘  └─┘  └─┘       └─────────────┘ 
520        ⟨v, u, hv, hu, ha₂, ha₁, assume ⟨b₁, b₂⟩ ⟨h₁, h₂⟩, not_le_of_gt $ h b₂ h₂ b₁ h₁⟩ }
id                                         └┘  └┘  └┘  └┘   └──────────┘
src                                                           └──────────┘
typ                                        └┘  └┘  └┘  └┘   └──────────┘
521  
522  lemma order_topology.t2_space : t2_space α := by apply_instance
id                                   └──────┘ 
src                                  └──────┘         └──────────────
typ                                  └──────┘        └──────────────
doc                                  └──────┘         └──────────────
txt                                                   └──────────────
par                                                   └──────────────
pid                                                                 
st                                                   └───────────────
523  
src  
typ  
doc  
txt  
par  
pid  
st   
524  @[priority 100] -- see Note [lower instance priority]
525  instance order_topology.regular_space : regular_space α :=
id                                           └───────────┘ 
src                                          └───────────┘
typ                                          └───────────┘ 
doc                                          └───────────┘
526  { regular := assume s a hs ha,
id                         └┘ └┘
typ                        └┘ └┘
527      have hs' : -s ∈ 𝓝 a, from mem_nhds_sets hs ha,
id                            └───────────┘ └┘ └┘
src                             └───────────┘
typ                           └───────────┘ └┘ └┘
doc                      
528      have ∃t:set α, is_open t ∧ (∀l∈ s, l < a → l ∈ t) ∧ 𝓝 a ⊓ principal t = ⊥,
id              └─┘  └─────┘                      └───────┘   
src             └─┘   └─────┘                              └───────┘    
typ             └─┘  └─────┘                      └───────┘   
doc                     └─────┘                                   └───────┘
529        from by_cases
id              └──────┘
src             └──────┘
typ             └──────┘
530          (assume h : ∃l, l < a,
id                          
src                          
typ                         
531            let ⟨l, hl, h⟩ := exists_Ioc_subset_of_mem_nhds hs' h in
id             └─┘    └┘       └───────────────────────────┘ └─┘ 
src                              └───────────────────────────┘
typ            └─┘    └┘       └───────────────────────────┘ └─┘ 
532            match dense_or_discrete l a with
id                   └───────────────┘   
src                  └───────────────┘
typ                  └───────────────┘   
533            | or.inl ⟨b, hb₁, hb₂⟩ := ⟨{a | a < b}, is_open_gt' _,
id               └────┘    └─┘  └─┘               └─────────┘
src              └────┘                              └─────────┘
typ              └────┘    └─┘  └─┘               └─────────┘
534                assume c hcs hca, show c < b,
id                         └─┘ └─┘        
src                                         
typ                        └─┘ └─┘        
535                  from lt_of_not_ge $ assume hbc, h ⟨lt_of_lt_of_le hb₁ hbc, le_of_lt hca⟩ hcs,
id                        └──────────┘          └─┘     └────────────┘     └─┘  └──────┘ └─┘  └─┘
src                       └──────────┘                  └────────────┘          └──────┘
typ                       └──────────┘          └─┘     └────────────┘     └─┘  └──────┘ └─┘  └─┘
536                inf_principal_eq_bot $ (𝓝 a).sets_of_superset (mem_nhds_sets (is_open_lt' _) hb₂) $
id                 └──────────────────┘      └──────────────┘   └───────────┘  └─────────┘
src                └──────────────────┘       └──────────────┘   └───────────┘  └─────────┘
typ                └──────────────────┘      └──────────────┘   └───────────┘  └─────────┘
doc                                        
537                  assume x (hx : b < x), show ¬ x < b, from not_lt.2 $ le_of_lt hx⟩
id                                                       └────┘    └──────┘ └┘
src                                                         └────┘    └──────┘
typ                                                      └────┘    └──────┘ └┘
538            | or.inr ⟨h₁, h₂⟩ := ⟨{a' | a' < a}, is_open_gt' _, assume b hbs hba, hba,
id               └────┘  └┘          └┘   └┘     └─────────┘            └─┘ └─┘  └─┘
src              └────┘                           └─────────┘
typ              └────┘  └┘          └┘   └┘     └─────────┘            └─┘ └─┘  └─┘
539                inf_principal_eq_bot $ (𝓝 a).sets_of_superset (mem_nhds_sets (is_open_lt' _) hl) $
id                 └──────────────────┘      └──────────────┘   └───────────┘  └─────────┘
src                └──────────────────┘       └──────────────┘   └───────────┘  └─────────┘
typ                └──────────────────┘      └──────────────┘   └───────────┘  └─────────┘
doc                                        
540                  assume x (hx : l < x), show ¬ x < a, from not_lt.2 $ h₁ _ hx⟩
id                                                      └────┘         └┘
src                                                         └────┘
typ                                                     └────┘         └┘
541            end)
542          (assume : ¬ ∃l, l < a, ⟨∅, is_open_empty, assume l _ hl, (this ⟨l, hl⟩).elim,
id                              └───────────┘           └┘   └──┘    └┘  └──┘
src                                └───────────┘                               └──┘
typ                             └───────────┘           └┘   └──┘    └┘  └──┘
543            by rw [principal_empty, inf_bot_eq]⟩),
id                    └─────────────┘  └────────┘
src               └──┘└─────────────┘└┘└────────┘
typ               └──┘└─────────────┘└┘└────────┘
doc               └──┘               └┘          
txt               └──┘               └┘          
par               └──┘               └┘          
pid                 └┘               └┘          
st               └──────────────────┘└──────────┘
544      let ⟨t₁, ht₁o, ht₁s, ht₁a⟩ := this in
id       └─┘  └┘  └──┘  └──┘           └──┘
typ      └─┘  └┘  └──┘  └──┘           └──┘
545      have ∃t:set α, is_open t ∧ (∀u∈ s, u>a → u ∈ t) ∧ 𝓝 a ⊓ principal t = ⊥,
id              └─┘  └─────┘                    └───────┘   
src             └─┘   └─────┘                            └───────┘    
typ             └─┘  └─────┘                    └───────┘   
doc                     └─────┘                                 └───────┘
546        from by_cases
id              └──────┘
src             └──────┘
typ             └──────┘
547          (assume h : ∃u, u > a,
id                          
src                          
typ                         
548            let ⟨u, hu, h⟩ := exists_Ico_subset_of_mem_nhds hs' h in
id             └─┘    └┘       └───────────────────────────┘ └─┘ 
src                              └───────────────────────────┘
typ            └─┘    └┘       └───────────────────────────┘ └─┘ 
549            match dense_or_discrete a u with
id                   └───────────────┘ 
src                  └───────────────┘
typ                  └───────────────┘ 
550            | or.inl ⟨b, hb₁, hb₂⟩ := ⟨{a | b < a}, is_open_lt' _,
id               └────┘    └─┘  └─┘               └─────────┘
src              └────┘                              └─────────┘
typ              └────┘    └─┘  └─┘               └─────────┘
551                assume c hcs hca, show c > b,
id                         └─┘ └─┘        
src                                         
typ                        └─┘ └─┘        
552                  from lt_of_not_ge $ assume hbc, h ⟨le_of_lt hca, lt_of_le_of_lt hbc hb₂⟩ hcs,
id                        └──────────┘          └─┘     └──────┘ └─┘  └────────────┘ └─┘      └─┘
src                       └──────────┘                  └──────┘      └────────────┘
typ                       └──────────┘          └─┘     └──────┘ └─┘  └────────────┘ └─┘      └─┘
553                inf_principal_eq_bot $ (𝓝 a).sets_of_superset (mem_nhds_sets (is_open_gt' _) hb₁) $
id                 └──────────────────┘      └──────────────┘   └───────────┘  └─────────┘
src                └──────────────────┘       └──────────────┘   └───────────┘  └─────────┘
typ                └──────────────────┘      └──────────────┘   └───────────┘  └─────────┘
doc                                        
554                  assume x (hx : b > x), show ¬ x > b, from not_lt.2 $ le_of_lt hx⟩
id                                                       └────┘    └──────┘ └┘
src                                                         └────┘    └──────┘
typ                                                      └────┘    └──────┘ └┘
555            | or.inr ⟨h₁, h₂⟩ := ⟨{a' | a' > a}, is_open_lt' _, assume b hbs hba, hba,
id               └────┘      └┘      └┘   └┘     └─────────┘            └─┘ └─┘  └─┘
src              └────┘                           └─────────┘
typ              └────┘      └┘      └┘   └┘     └─────────┘            └─┘ └─┘  └─┘
556                inf_principal_eq_bot $ (𝓝 a).sets_of_superset (mem_nhds_sets (is_open_gt' _) hu) $
id                 └──────────────────┘      └──────────────┘   └───────────┘  └─────────┘
src                └──────────────────┘       └──────────────┘   └───────────┘  └─────────┘
typ                └──────────────────┘      └──────────────┘   └───────────┘  └─────────┘
doc                                        
557                  assume x (hx : u > x), show ¬ x > a, from not_lt.2 $ h₂ _ hx⟩
id                                                      └────┘         └┘
src                                                         └────┘
typ                                                     └────┘         └┘
558            end)
559          (assume : ¬ ∃u, u > a, ⟨∅, is_open_empty, assume l _ hl, (this ⟨l, hl⟩).elim,
id                              └───────────┘           └┘   └──┘    └┘  └──┘
src                                └───────────┘                               └──┘
typ                             └───────────┘           └┘   └──┘    └┘  └──┘
560            by rw [principal_empty, inf_bot_eq]⟩),
id                    └─────────────┘  └────────┘
src               └──┘└─────────────┘└┘└────────┘
typ               └──┘└─────────────┘└┘└────────┘
doc               └──┘               └┘          
txt               └──┘               └┘          
par               └──┘               └┘          
pid                 └┘               └┘          
st               └──────────────────┘└──────────┘
561      let ⟨t₂, ht₂o, ht₂s, ht₂a⟩ := this in
id       └─┘  └┘  └──┘  └──┘           └──┘
typ      └─┘  └┘  └──┘  └──┘           └──┘
562      ⟨t₁ ∪ t₂, is_open_union ht₁o ht₂o,
id                └───────────┘
src               └───────────┘
typ               └───────────┘
563        assume x hx,
id                 └┘
typ                └┘
564        have x ≠ a, from assume eq, ha $ eq ▸ hx,
id                              └┘  └┘   └┘  └┘
src                               └┘       └┘ 
typ                             └┘  └┘   └┘  └┘
565        (ne_iff_lt_or_gt.mp this).imp (ht₁s _ hx) (ht₂s _ hx),
id          └─────────────┘└─┘ └──┘ └─┘          └┘          └┘
src         └─────────────┘└─┘      └─┘
typ         └─────────────┘└─┘ └──┘ └─┘          └┘          └┘
566        by rw [←sup_principal, inf_sup_left, ht₁a, ht₂a, bot_sup_eq]⟩,
id                 └───────────┘  └──────────┘  └──┘  └──┘  └────────┘
src           └───┘└───────────┘└┘└──────────┘└┘    └┘    └┘└────────┘
typ           └───┘└───────────┘└┘└──────────┘└┘└──┘└┘└──┘└┘└────────┘
doc           └───┘             └┘            └┘    └┘    └┘          
txt           └───┘             └┘            └┘    └┘    └┘          
par           └───┘             └┘            └┘    └┘    └┘          
pid             └─┘             └┘            └┘    └┘    └┘          
st           └─────────────────┘└────────────┘└────┘└────┘└──────────┘
567    ..order_topology.t2_space }
id       └─────────────────────┘
src      └─────────────────────┘
typ      └─────────────────────┘
568  
569  /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`,
570  provided `a` is neither a bottom element nor a top element. -/
571  lemma mem_nhds_iff_exists_Ioo_subset' {a l' u' : α} {s : set α}
id                                                           └─┘ 
src                                                           └─┘
typ                                                          └─┘ 
572    (hl' : l' < a) (hu' : a < u') :
id            └┘             └┘
src                           
typ           └┘             └┘
573    s ∈ 𝓝 a ↔ ∃l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s :=
id              └─┘    └─┘    
src                  └─┘      └─┘     
typ             └─┘    └─┘    
doc                       └─┘       └─┘
574  begin
st   └─────
575    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
576    { assume h,
src      └──────┘
typ      └──────┘
doc      └──────┘
txt      └──────┘
par      └──────┘
pid      └──────┘
st   ───┘└──────┘└─
577      rcases exists_Ico_subset_of_mem_nhds' h hu' with ⟨u, au, hu⟩,
id              └────────────────────────────┘  └─┘
src      └─────┘└────────────────────────────┘    └───────────────┘
typ      └─────┘└────────────────────────────┘└─┘└───────────────┘
doc      └─────┘                                  └───────────────┘
txt      └─────┘                                  └───────────────┘
par      └─────┘                                  └───────────────┘
pid                                              └───────────────┘
st   ───────────────────────────────────────────────────────────────┘└─
578      rcases exists_Ioc_subset_of_mem_nhds' h hl' with ⟨l, la, hl⟩,
id              └────────────────────────────┘  └─┘
src      └─────┘└────────────────────────────┘    └───────────────┘
typ      └─────┘└────────────────────────────┘└─┘└───────────────┘
doc      └─────┘                                  └───────────────┘
txt      └─────┘                                  └───────────────┘
par      └─────┘                                  └───────────────┘
pid                                              └───────────────┘
st   ───────────────────────────────────────────────────────────────┘└─
579      refine ⟨l, u, ⟨la.2, au.1⟩, λx hx, _⟩,
id                    └┘    └┘
src      └─────┘  └┘ └┘   └──┘  └───┘ └──────┘
typ      └─────┘ └┘└┘ └┘└──┘└┘└───┘ └──────┘
doc      └─────┘  └┘ └┘   └──┘  └───┘ └──────┘
txt      └─────┘  └┘ └┘   └──┘  └───┘ └──────┘
par      └─────┘  └┘ └┘   └──┘  └───┘ └──────┘
pid              └┘ └┘   └──┘  └───┘ └──────┘
st   ────────────────────────────────────────┘└─
580      cases le_total a x with hax hax,
id             └──────┘  
src      └────┘└──────┘  └───────────┘
typ      └────┘└──────┘└───────────┘
doc      └────┘          └───────────┘
txt      └────┘          └───────────┘
par      └────┘          └───────────┘
pid                     └───────────┘
st   ──────────────────────────────────┘└─
581      { exact hu ⟨hax, hx.2⟩ },
id               └┘  └─┘  └┘
src        └────┘      └┘  └──┘
typ        └────┘└┘ └─┘└┘└┘└──┘
doc        └────┘      └┘  └──┘
txt        └────┘      └┘  └──┘
par        └────┘      └┘  └──┘
pid                   └┘  └─┘
st   ─────┘└───────────────────┘└┘
582      { exact hl ⟨hx.1, hax⟩ } },
id               └┘  └┘    └─┘
src        └────┘     └──┘   └┘
typ        └────┘└┘ └┘└──┘└─┘└┘
doc        └────┘     └──┘   └┘
txt        └────┘     └──┘   └┘
par        └────┘     └──┘   └┘
pid                  └──┘   
st   ──────────────────────────┘└──┘
583    { rintros ⟨l, u, ha, h⟩,
src      └───────────────────┘
typ      └───────────────────┘
doc      └───────────────────┘
txt      └───────────────────┘
par      └───────────────────┘
pid             └────────────┘
st   ────────────────────────┘└─
584      apply mem_sets_of_superset (mem_nhds_sets is_open_Ioo ha) h }
id             └──────────────────┘  └───────────┘ └─────────┘ └┘  
src      └────┘└──────────────────┘ └───────────┘└─────────┘  └┘ 
typ      └────┘└──────────────────┘ └───────────┘└─────────┘└┘└┘
doc      └────┘                                               └┘ 
txt      └────┘                                               └┘ 
par      └────┘                                               └┘ 
pid                                                          └┘ 
st   ───────────────────────────────────────────────────────────────┘└─
585  end
st   ──┘
586  
587  /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/
588  lemma mem_nhds_iff_exists_Ioo_subset [no_top_order α] [no_bot_order α] {a : α} {s : set α} :
id                                         └──────────┘    └──────────┘               └─┘ 
src                                        └──────────┘     └──────────┘                 └─┘
typ                                        └──────────┘    └──────────┘               └─┘ 
doc                                        └──────────┘     └──────────┘
589    s ∈ 𝓝 a ↔ ∃l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s :=
id              └─┘    └─┘    
src                  └─┘      └─┘     
typ             └─┘    └─┘    
doc                       └─┘       └─┘
590  let ⟨l', hl'⟩ := no_bot a in let ⟨u', hu'⟩ := no_top a in mem_nhds_iff_exists_Ioo_subset' hl' hu'
id   └─┘      └─┘     └────┘     └─┘      └─┘     └────┘     └─────────────────────────────┘
src                   └────┘                       └────┘      └─────────────────────────────┘
typ  └─┘      └─┘     └────┘     └─┘      └─┘     └────┘     └─────────────────────────────┘
doc                                                            └─────────────────────────────┘
591  
592  /-!
593  ### Neighborhoods to the left and to the right
594  
595  Limits to the left and to the right of real functions are defined in terms of neighborhoods to
596  the left and to the right, either open or closed, i.e., members of `nhds_within a (Ioi a)` and
597  `nhds_wihin a (Ici a)` on the right, and similarly on the left. Such neighborhoods can be
598  characterized as the sets containing suitable intervals to the right or to the left of `a`.
599  We give now these characterizations. -/
600  
601  -- NB: If you extend the list, append to the end please to avoid breaking the API
602  /-- The following statements are equivalent:
603  
604  0. `s` is a neighborhood of `a` within `(a, +∞)`
605  1. `s` is a neighborhood of `a` within `(a, b]`
606  2. `s` is a neighborhood of `a` within `(a, b)`
607  3. `s` includes `(a, u)` for some `u ∈ (a, b]`
608  4. `s` includes `(a, u)` for some `u > a` -/
609  lemma tfae_mem_nhds_within_Ioi {a b : α} (hab : a < b) (s : set α) :
id                                                           └─┘ 
src                                                             └─┘
typ                                                          └─┘ 
610    tfae [s ∈ nhds_within a (Ioi a), -- 0 : `s` is a neighborhood of `a` within `(a, +∞)`
id     └──┘   └─────────┘   └─┘  
src    └──┘    └─────────┘    └─┘   
typ    └──┘   └─────────┘   └─┘  
doc              └─────────┘    └─┘
611      s ∈ nhds_within a (Ioc a b),   -- 1 : `s` is a neighborhood of `a` within `(a, b]`
id         └─────────┘   └─┘   
src         └─────────┘    └─┘     
typ        └─────────┘   └─┘   
doc          └─────────┘    └─┘
612      s ∈ nhds_within a (Ioo a b),   -- 2 : `s` is a neighborhood of `a` within `(a, b)`
id         └─────────┘   └─┘   
src         └─────────┘    └─┘     
typ        └─────────┘   └─┘   
doc          └─────────┘    └─┘
613      ∃ u ∈ Ioc a b, Ioo a u ⊆ s,    -- 3 : `s` includes `(a, u)` for some `u ∈ (a, b]`
id           └─┘   └─┘    
src           └─┘     └─┘       
typ          └─┘   └─┘    
doc            └─┘      └─┘
614      ∃ u ∈ Ioi a, Ioo a u ⊆ s] :=   -- 4 : `s` includes `(a, u)` for some `u > a`
id           └─┘ └┘ └─┘    
src           └─┘   └─┘       
typ          └─┘  └─┘    
doc            └─┘    └─┘
615  begin
st   └─────
616    tfae_have : 1 → 2, from λ h, nhds_within_mono _ Ioc_subset_Ioi_self h,
id                                  └──────────────┘   └─────────────────┘
src    └───────────────┘  └───┘ └──┘└──────────────┘└─┘└─────────────────┘
typ    └───────────────┘  └───┘ └──┘└──────────────┘└─┘└─────────────────┘
doc    └───────────────┘  └───┘ └──┘                └─┘                   
txt    └───────────────┘  └───┘ └──┘                └─┘                   
par    └───────────────┘  └───┘ └──┘                └─┘                   
pid             └┘└─┘  └───┘ └──┘                └─┘                   
st   ──────────────────┘└──────────────────────────────────────────────────┘└─
617    tfae_have : 2 → 3, from λ h, nhds_within_mono _ Ioo_subset_Ioc_self h,
id                                  └──────────────┘   └─────────────────┘
src    └───────────────┘  └───┘ └──┘└──────────────┘└─┘└─────────────────┘
typ    └───────────────┘  └───┘ └──┘└──────────────┘└─┘└─────────────────┘
doc    └───────────────┘  └───┘ └──┘                └─┘                   
txt    └───────────────┘  └───┘ └──┘                └─┘                   
par    └───────────────┘  └───┘ └──┘                └─┘                   
pid             └┘└─┘  └───┘ └──┘                └─┘                   
st   ──────────────────┘└──────────────────────────────────────────────────┘└─
618    tfae_have : 4 → 5, from λ ⟨u, umem, hu⟩, ⟨u, umem.1, hu⟩,
id                                  └──┘  └┘
src    └───────────────┘  └───┘ └┘ └┘    └┘  └─┘  └┘    └──┘  
typ    └───────────────┘  └───┘ └┘└┘└──┘└┘└┘└─┘  └┘    └──┘  
doc    └───────────────┘  └───┘ └┘ └┘    └┘  └─┘  └┘    └──┘  
txt    └───────────────┘  └───┘ └┘ └┘    └┘  └─┘  └┘    └──┘  
par    └───────────────┘  └───┘ └┘ └┘    └┘  └─┘  └┘    └──┘  
pid             └┘└─┘  └───┘ └┘ └┘    └┘  └─┘  └┘    └──┘  
st   ──────────────────┘└─────────────────────────────────────┘└─
619    tfae_have : 5 → 1,
src    └───────────────┘
typ    └───────────────┘
doc    └───────────────┘
txt    └───────────────┘
par    └───────────────┘
pid             └┘└─┘
st   ──────────────────┘└─
620    { rintros ⟨u, hau, hu⟩,
src      └──────────────────┘
typ      └──────────────────┘
doc      └──────────────────┘
txt      └──────────────────┘
par      └──────────────────┘
pid             └───────────┘
st   ───┘└──────────────────┘└─
621      exact mem_nhds_within.2 ⟨Iio u, is_open_Iio, hau, by rwa [inter_comm, Ioi_inter_Iio]⟩ },
id             └─────────────┘    └─┘   └─────────┘  └─┘          └────────┘  └───────────┘
src      └────┘└─────────────┘└─┘ └─┘ └┘└─────────┘└┘   └┘  └───┘└────────┘└┘└───────────┘└┘
typ      └────┘└─────────────┘└─┘ └─┘└┘└─────────┘└┘└─┘└┘  └───┘└────────┘└┘└───────────┘└┘
doc      └────┘               └─┘ └─┘ └┘           └┘   └┘  └───┘          └┘             └┘
txt      └────┘               └─┘     └┘           └┘   └┘  └───┘          └┘             └┘
par      └────┘               └─┘     └┘           └┘   └┘  └───┘          └┘             └┘
pid                          └─┘     └┘           └┘   └┘  └────┘          └┘             └┘
st   ───────────────────────────────────────────────────────┘└──────────────┘└─────────────┘└┘└┘
622    tfae_have : 3 → 4,
src    └───────────────┘
typ    └───────────────┘
doc    └───────────────┘
txt    └───────────────┘
par    └───────────────┘
pid             └┘└─┘
st   ──────────────────┘└─
623    { assume h,
src      └──────┘
typ      └──────┘
doc      └──────┘
txt      └──────┘
par      └──────┘
pid      └──────┘
st   ───┘└──────┘└─
624      rcases mem_nhds_within_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩,
id              └───────────────────────────────────────┘   
src      └─────┘└───────────────────────────────────────┘└─┘ └───────────────┘
typ      └─────┘└───────────────────────────────────────┘└─┘└───────────────┘
doc      └─────┘                                         └─┘ └───────────────┘
txt      └─────┘                                         └─┘ └───────────────┘
par      └─────┘                                         └─┘ └───────────────┘
pid                                                     └─┘ └───────────────┘
st   ────────────────────────────────────────────────────────────────────────┘└─
625      rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩,
id              └────────────────────────────┘ └┘ └─┘
src      └─────┘└────────────────────────────┘     └───────────────┘
typ      └─────┘└────────────────────────────┘└┘└─┘└───────────────┘
doc      └─────┘                                   └───────────────┘
txt      └─────┘                                   └───────────────┘
par      └─────┘                                   └───────────────┘
pid                                               └───────────────┘
st   ────────────────────────────────────────────────────────────────┘└─
626      refine ⟨u, au, λx hx, _⟩,
id                 └┘
src      └─────┘  └┘  └┘ └──────┘
typ      └─────┘ └┘└┘└┘ └──────┘
doc      └─────┘  └┘  └┘ └──────┘
txt      └─────┘  └┘  └┘ └──────┘
par      └─────┘  └┘  └┘ └──────┘
pid              └┘  └┘ └──────┘
st   ───────────────────────────┘└─
627      refine hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩,
id              └┘  └┘  └──────┘       └┘
src      └─────┘      └──────┘  └──┘  └─────┘
typ      └─────┘└┘ └┘ └──────┘  └──┘└┘└─────┘
doc      └─────┘                └──┘  └─────┘
txt      └─────┘                └──┘  └─────┘
par      └─────┘                └──┘  └─────┘
pid                            └──┘  └─────┘
st   ──────────────────────────────────────────┘└─
628      exact Ioo_subset_Ioo_right au.2 hx  },
id             └──────────────────┘ └┘   └┘
src      └────┘└──────────────────┘  └─┘  └┘
typ      └────┘└──────────────────┘└┘└─┘└┘└┘
doc      └────┘                      └─┘  └┘
txt      └────┘                      └─┘  └┘
par      └────┘                      └─┘  └┘
pid                                 └─┘  └┘
st   ───────────────────────────────────────┘└┘
629    tfae_finish
src    └──────────┘
typ    └──────────┘
doc    └──────────┘
txt    └──────────┘
par    └──────────┘
pid               
st   ─────────────┘
630  end
st   └─┘
631  
632  @[simp] lemma nhds_within_Ioc_eq_nhds_within_Ioi {a b : α} (h : a < b) :
id                                                                    
src                                                                    
typ                                                                   
doc    └──┘
633    nhds_within a (Ioc a b) = nhds_within a (Ioi a) :=
id     └─────────┘   └─┘     └─────────┘   └─┘ 
src    └─────────┘    └─┘       └─────────┘    └─┘
typ    └─────────┘   └─┘     └─────────┘   └─┘ 
doc    └─────────┘    └─┘        └─────────┘    └─┘
634  filter.ext $ λ s, (tfae_mem_nhds_within_Ioi h s).out 1 0
id   └────────┘        └──────────────────────┘   └─┘
src  └────────┘         └──────────────────────┘     └─┘
typ  └────────┘        └──────────────────────┘   └─┘
doc                     └──────────────────────┘     └─┘
635  
636  @[simp] lemma nhds_within_Ioo_eq_nhds_within_Ioi {a b : α} (hu : a < b) :
id                                                                     
src                                                                     
typ                                                                    
doc    └──┘
637    nhds_within a (Ioo a b) = nhds_within a (Ioi a) :=
id     └─────────┘   └─┘     └─────────┘   └─┘ 
src    └─────────┘    └─┘       └─────────┘    └─┘
typ    └─────────┘   └─┘     └─────────┘   └─┘ 
doc    └─────────┘    └─┘        └─────────┘    └─┘
638  filter.ext $ λ s, (tfae_mem_nhds_within_Ioi hu s).out 2 0
id   └────────┘        └──────────────────────┘ └┘  └─┘
src  └────────┘         └──────────────────────┘      └─┘
typ  └────────┘        └──────────────────────┘ └┘  └─┘
doc                     └──────────────────────┘      └─┘
639  
640  lemma mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : set α} (hu' : a < u') :
id                                                                          └─┘            └┘
src                                                                          └─┘             
typ                                                                         └─┘            └┘
641    s ∈ nhds_within a (Ioi a) ↔ ∃u ∈ Ioc a u', Ioo a u ⊆ s :=
id       └─────────┘   └─┘       └─┘  └┘ └─┘    
src       └─────────┘    └─┘         └─┘      └─┘     
typ      └─────────┘   └─┘       └─┘  └┘ └─┘    
doc        └─────────┘    └─┘           └─┘       └─┘
642  (tfae_mem_nhds_within_Ioi hu' s).out 0 3
id    └──────────────────────┘ └─┘  └─┘
src   └──────────────────────┘       └─┘
typ   └──────────────────────┘ └─┘  └─┘
doc   └──────────────────────┘       └─┘
643  
644  /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)`
645  with `a < u < u'`, provided `a` is not a top element. -/
646  lemma mem_nhds_within_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : set α} (hu' : a < u') :
id                                                                   └─┘            └┘
src                                                                   └─┘             
typ                                                                  └─┘            └┘
647    s ∈ nhds_within a (Ioi a) ↔ ∃u ∈ Ioi a, Ioo a u ⊆ s :=
id       └─────────┘   └─┘       └─┘  └─┘    
src       └─────────┘    └─┘         └─┘   └─┘     
typ      └─────────┘   └─┘       └─┘  └─┘    
doc        └─────────┘    └─┘           └─┘    └─┘
648  (tfae_mem_nhds_within_Ioi hu' s).out 0 4
id    └──────────────────────┘ └─┘  └─┘
src   └──────────────────────┘       └─┘
typ   └──────────────────────┘ └─┘  └─┘
doc   └──────────────────────┘       └─┘
649  
650  /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)`
651  with `a < u`. -/
652  lemma mem_nhds_within_Ioi_iff_exists_Ioo_subset [no_top_order α] {a : α} {s : set α} :
id                                                    └──────────┘               └─┘ 
src                                                   └──────────┘                 └─┘
typ                                                   └──────────┘               └─┘ 
doc                                                   └──────────┘
653    s ∈ nhds_within a (Ioi a) ↔ ∃u ∈ Ioi a, Ioo a u ⊆ s :=
id       └─────────┘   └─┘       └─┘  └─┘    
src       └─────────┘    └─┘         └─┘   └─┘     
typ      └─────────┘   └─┘       └─┘  └─┘    
doc        └─────────┘    └─┘           └─┘    └─┘
654  let ⟨u', hu'⟩ := no_top a in mem_nhds_within_Ioi_iff_exists_Ioo_subset' hu'
id   └─┘      └─┘     └────┘     └────────────────────────────────────────┘
src                   └────┘      └────────────────────────────────────────┘
typ  └─┘      └─┘     └────┘     └────────────────────────────────────────┘
doc                               └────────────────────────────────────────┘
655  
656  /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]`
657  with `a < u`. -/
658  lemma mem_nhds_within_Ioi_iff_exists_Ioc_subset [no_top_order α] [densely_ordered α]
id                                                    └──────────┘    └─────────────┘ 
src                                                   └──────────┘     └─────────────┘
typ                                                   └──────────┘    └─────────────┘ 
doc                                                   └──────────┘     └─────────────┘
659    {a : α} {s : set α} : s ∈ nhds_within a (Ioi a) ↔ ∃u ∈ Ioi a, Ioc a u ⊆ s :=
id                 └─┘       └─────────┘   └─┘       └─┘  └─┘    
src                 └─┘         └─────────┘    └─┘         └─┘   └─┘     
typ                └─┘       └─────────┘   └─┘       └─┘  └─┘    
doc                              └─────────┘    └─┘           └─┘    └─┘
660  begin
st   └─────
661    rw mem_nhds_within_Ioi_iff_exists_Ioo_subset,
id        └───────────────────────────────────────┘
src    └─┘└───────────────────────────────────────┘
typ    └─┘└───────────────────────────────────────┘
doc    └─┘└───────────────────────────────────────┘
txt    └─┘
par    └─┘
pid      
st   ─────────────────────────────────────────────┘└─
662    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
663    { rintros ⟨u, au, as⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ───┘└─────────────────┘└─
664      rcases dense au with ⟨v, hv⟩,
id              └───┘ └┘
src      └─────┘└───┘  └───────────┘
typ      └─────┘└───┘└┘└───────────┘
doc      └─────┘       └───────────┘
txt      └─────┘       └───────────┘
par      └─────┘       └───────────┘
pid                   └───────────┘
st   ───────────────────────────────┘└─
665      exact ⟨v, hv.1, λx hx, as ⟨hx.1, lt_of_le_of_lt hx.2 hv.2⟩⟩ },
id                             └┘        └────────────┘      └┘
src      └────┘  └┘  └──┘ └────┘     └──┘└────────────┘  └─┘  └───┘
typ      └────┘ └┘  └──┘ └────┘└┘   └──┘└────────────┘  └─┘└┘└───┘
doc      └────┘  └┘  └──┘ └────┘     └──┘                └─┘  └───┘
txt      └────┘  └┘  └──┘ └────┘     └──┘                └─┘  └───┘
par      └────┘  └┘  └──┘ └────┘     └──┘                └─┘  └───┘
pid             └┘  └──┘ └────┘     └──┘                └─┘  └──┘
st   ───────────────────────────────────────────────────────────────┘└┘
666    { rintros ⟨u, au, as⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ──────────────────────┘└─
667      exact ⟨u, au, subset.trans Ioo_subset_Ioc_self as⟩ }
id                └┘  └──────────┘ └─────────────────┘ └┘
src      └────┘  └┘  └┘└──────────┘└─────────────────┘  └┘
typ      └────┘ └┘└┘└┘└──────────┘└─────────────────┘└┘└┘
doc      └────┘  └┘  └┘                                 └┘
txt      └────┘  └┘  └┘                                 └┘
par      └────┘  └┘  └┘                                 └┘
pid             └┘  └┘                                 
st   ──────────────────────────────────────────────────────┘└─
668  end
st   ──┘
669  
670  lemma Ioo_mem_nhds_within_Ioi {a b c : α} (H : b ∈ Ico a c) :
id                                                   └─┘  
src                                                    └─┘
typ                                                  └─┘  
doc                                                     └─┘
671    Ioo a c ∈ nhds_within b (Ioi b) :=
id     └─┘    └─────────┘   └─┘ 
src    └─┘      └─────────┘    └─┘
typ    └─┘    └─────────┘   └─┘ 
doc    └─┘       └─────────┘    └─┘
672  (mem_nhds_within_Ioi_iff_exists_Ioo_subset' H.2).2 ⟨c, H.2, Ioo_subset_Ioo_left H.1⟩
id    └────────────────────────────────────────┘           └─────────────────┘ 
src   └────────────────────────────────────────┘              └─────────────────┘  
typ   └────────────────────────────────────────┘           └─────────────────┘ 
doc   └────────────────────────────────────────┘
673  
674  lemma Ioc_mem_nhds_within_Ioi {a b c : α} (H : b ∈ Ico a c) :
id                                                   └─┘  
src                                                    └─┘
typ                                                  └─┘  
doc                                                     └─┘
675    Ioc a c ∈ nhds_within b (Ioi b) :=
id     └─┘    └─────────┘   └─┘ 
src    └─┘      └─────────┘    └─┘
typ    └─┘    └─────────┘   └─┘ 
doc    └─┘       └─────────┘    └─┘
676  mem_sets_of_superset (Ioo_mem_nhds_within_Ioi H) Ioo_subset_Ioc_self
id   └──────────────────┘  └─────────────────────┘   └─────────────────┘
src  └──────────────────┘  └─────────────────────┘    └─────────────────┘
typ  └──────────────────┘  └─────────────────────┘   └─────────────────┘
677  
678  lemma Ico_mem_nhds_within_Ioi {a b c : α} (H : b ∈ Ico a c) :
id                                                   └─┘  
src                                                    └─┘
typ                                                  └─┘  
doc                                                     └─┘
679    Ico a c ∈ nhds_within b (Ioi b) :=
id     └─┘    └─────────┘   └─┘ 
src    └─┘      └─────────┘    └─┘
typ    └─┘    └─────────┘   └─┘ 
doc    └─┘       └─────────┘    └─┘
680  mem_sets_of_superset (Ioo_mem_nhds_within_Ioi H) Ioo_subset_Ico_self
id   └──────────────────┘  └─────────────────────┘   └─────────────────┘
src  └──────────────────┘  └─────────────────────┘    └─────────────────┘
typ  └──────────────────┘  └─────────────────────┘   └─────────────────┘
681  
682  lemma Icc_mem_nhds_within_Ioi {a b c : α} (H : b ∈ Ico a c) :
id                                                   └─┘  
src                                                    └─┘
typ                                                  └─┘  
doc                                                     └─┘
683    Icc a c ∈ nhds_within b (Ioi b) :=
id     └─┘    └─────────┘   └─┘ 
src    └─┘      └─────────┘    └─┘
typ    └─┘    └─────────┘   └─┘ 
doc    └─┘       └─────────┘    └─┘
684  mem_sets_of_superset (Ioo_mem_nhds_within_Ioi H) Ioo_subset_Icc_self
id   └──────────────────┘  └─────────────────────┘   └─────────────────┘
src  └──────────────────┘  └─────────────────────┘    └─────────────────┘
typ  └──────────────────┘  └─────────────────────┘   └─────────────────┘
685  
686  /-- The following statements are equivalent:
687  
688  0. `s` is a neighborhood of `b` within `(-∞, b)`
689  1. `s` is a neighborhood of `b` within `[a, b)`
690  2. `s` is a neighborhood of `b` within `(a, b)`
691  3. `s` includes `(l, b)` for some `l ∈ [a, b)`
692  4. `s` includes `(l, b)` for some `l < b` -/
693  lemma tfae_mem_nhds_within_Iio {a b : α} (h : a < b) (s : set α) :
id                                                         └─┘ 
src                                                           └─┘
typ                                                        └─┘ 
694    tfae [s ∈ nhds_within b (Iio b), -- 0 : `s` is a neighborhood of `b` within `(-∞, b)`
id     └──┘   └─────────┘   └─┘  
src    └──┘    └─────────┘    └─┘   
typ    └──┘   └─────────┘   └─┘  
doc              └─────────┘    └─┘
695      s ∈ nhds_within b (Ico a b),   -- 1 : `s` is a neighborhood of `b` within `[a, b)`
id         └─────────┘   └─┘   
src         └─────────┘    └─┘     
typ        └─────────┘   └─┘   
doc          └─────────┘    └─┘
696      s ∈ nhds_within b (Ioo a b),   -- 2 : `s` is a neighborhood of `b` within `(a, b)`
id         └─────────┘   └─┘   
src         └─────────┘    └─┘     
typ        └─────────┘   └─┘   
doc          └─────────┘    └─┘
697      ∃ l ∈ Ico a b, Ioo l b ⊆ s,    -- 3 : `s` includes `(l, b)` for some `l ∈ [a, b)`
id           └─┘   └─┘    
src           └─┘     └─┘       
typ          └─┘   └─┘    
doc            └─┘      └─┘
698      ∃ l ∈ Iio b, Ioo l b ⊆ s] :=   -- 4 : `s` includes `(l, b)` for some `l < b`
id           └─┘  └─┘    
src           └─┘   └─┘       
typ          └─┘  └─┘    
doc            └─┘    └─┘
699  begin
st   └─────
700    have := @tfae_mem_nhds_within_Ioi (order_dual α) _ _ _ _ _ h s,
id              └──────────────────────┘  └────────┘              
src    └──────┘ └──────────────────────┘ └────────┘ └──────────┘ 
typ    └──────┘ └──────────────────────┘ └────────┘└──────────┘
doc    └──────┘ └──────────────────────┘ └────────┘ └──────────┘ 
txt    └──────┘                                     └──────────┘ 
par    └──────┘                                     └──────────┘ 
pid    └───┘└─┘                                     └──────────┘ 
st   ───────────────────────────────────────────────────────────────┘└─
701    -- If we call `convert` here, it generates wrong equations, so we need to simplify first
st   ───────────────────────────────────────────────────────────────────────────────────────────
702    simp only [exists_prop] at this ⊢,
id                └─────────┘
src    └─────────┘└─────────┘└─────────┘
typ    └─────────┘└─────────┘└─────────┘
doc    └─────────┘           └─────────┘
txt    └─────────┘           └─────────┘
par    └─────────┘           └─────────┘
pid        └──┘└┘           └───────┘
st   ──────────────────────────────────┘└─
703    rw [dual_Ioi, dual_Ioc, dual_Ioo] at this,
id         └──────┘  └──────┘  └──────┘
src    └──┘└──────┘└┘└──────┘└┘└──────┘└───────┘
typ    └──┘└──────┘└┘└──────┘└┘└──────┘└───────┘
doc    └──┘        └┘        └┘        └───────┘
txt    └──┘        └┘        └┘        └───────┘
par    └──┘        └┘        └┘        └───────┘
pid      └┘        └┘        └┘        └──────┘
st   ─────────────┘└────────┘└────────┘└──────┘└─
704    convert this; ext l; rw [dual_Ioo]
id             └──┘             └──────┘
src    └──────┘      └───┘  └──┘└──────┘└┘
typ    └──────┘└──┘  └───┘  └──┘└──────┘└┘
doc    └──────┘      └───┘  └──┘        └┘
txt    └──────┘      └───┘  └──┘        └┘
par    └──────┘      └───┘  └──┘        └┘
pid                    └┘    └┘        
st   ──────────────────────────┘└──────┘
705  end
st   └─┘
706  
707  @[simp] lemma nhds_within_Ico_eq_nhds_within_Iio {a b : α} (h : a < b) :
id                                                                    
src                                                                    
typ                                                                   
doc    └──┘
708    nhds_within b (Ico a b) = nhds_within b (Iio b) :=
id     └─────────┘   └─┘     └─────────┘   └─┘ 
src    └─────────┘    └─┘       └─────────┘    └─┘
typ    └─────────┘   └─┘     └─────────┘   └─┘ 
doc    └─────────┘    └─┘        └─────────┘    └─┘
709  filter.ext $ λ s, (tfae_mem_nhds_within_Iio h s).out 1 0
id   └────────┘        └──────────────────────┘   └─┘
src  └────────┘         └──────────────────────┘     └─┘
typ  └────────┘        └──────────────────────┘   └─┘
doc                     └──────────────────────┘     └─┘
710  
711  @[simp] lemma nhds_within_Ioo_eq_nhds_within_Iio {a b : α} (h : a < b) :
id                                                                    
src                                                                    
typ                                                                   
doc    └──┘
712    nhds_within b (Ioo a b) = nhds_within b (Iio b) :=
id     └─────────┘   └─┘     └─────────┘   └─┘ 
src    └─────────┘    └─┘       └─────────┘    └─┘
typ    └─────────┘   └─┘     └─────────┘   └─┘ 
doc    └─────────┘    └─┘        └─────────┘    └─┘
713  filter.ext $ λ s, (tfae_mem_nhds_within_Iio h s).out 2 0
id   └────────┘        └──────────────────────┘   └─┘
src  └────────┘         └──────────────────────┘     └─┘
typ  └────────┘        └──────────────────────┘   └─┘
doc                     └──────────────────────┘     └─┘
714  
715  lemma mem_nhds_within_Iio_iff_exists_mem_Ico_Ioo_subset {a l' : α} {s : set α} (hl' : l' < a) :
id                                                                          └─┘          └┘  
src                                                                          └─┘              
typ                                                                         └─┘          └┘  
716    s ∈ nhds_within a (Iio a) ↔ ∃l ∈ Ico l' a, Ioo l a ⊆ s :=
id       └─────────┘   └─┘       └─┘ └┘  └─┘    
src       └─────────┘    └─┘         └─┘      └─┘     
typ      └─────────┘   └─┘       └─┘ └┘  └─┘    
doc        └─────────┘    └─┘           └─┘       └─┘
717  (tfae_mem_nhds_within_Iio hl' s).out 0 3
id    └──────────────────────┘ └─┘  └─┘
src   └──────────────────────┘       └─┘
typ   └──────────────────────┘ └─┘  └─┘
doc   └──────────────────────┘       └─┘
718  
719  /-- A set is a neighborhood of `a` within `(-∞, a)` if and only if it contains an interval `(l, a)`
720  with `l < a`, provided `a` is not a bottom element. -/
721  lemma mem_nhds_within_Iio_iff_exists_Ioo_subset' {a l' : α} {s : set α} (hl' : l' < a) :
id                                                                   └─┘          └┘  
src                                                                   └─┘              
typ                                                                  └─┘          └┘  
722    s ∈ nhds_within a (Iio a) ↔ ∃l ∈ Iio a, Ioo l a ⊆ s :=
id       └─────────┘   └─┘       └─┘  └─┘    
src       └─────────┘    └─┘         └─┘   └─┘     
typ      └─────────┘   └─┘       └─┘  └─┘    
doc        └─────────┘    └─┘           └─┘    └─┘
723  (tfae_mem_nhds_within_Iio hl' s).out 0 4
id    └──────────────────────┘ └─┘  └─┘
src   └──────────────────────┘       └─┘
typ   └──────────────────────┘ └─┘  └─┘
doc   └──────────────────────┘       └─┘
724  
725  /-- A set is a neighborhood of `a` within `(-∞, a)` if and only if it contains an interval `(l, a)`
726  with `l < a`. -/
727  lemma mem_nhds_within_Iio_iff_exists_Ioo_subset [no_bot_order α] {a : α} {s : set α} :
id                                                    └──────────┘               └─┘ 
src                                                   └──────────┘                 └─┘
typ                                                   └──────────┘               └─┘ 
doc                                                   └──────────┘
728    s ∈ nhds_within a (Iio a) ↔ ∃l ∈ Iio a, Ioo l a ⊆ s :=
id       └─────────┘   └─┘       └─┘  └─┘    
src       └─────────┘    └─┘         └─┘   └─┘     
typ      └─────────┘   └─┘       └─┘  └─┘    
doc        └─────────┘    └─┘           └─┘    └─┘
729  let ⟨l', hl'⟩ := no_bot a in mem_nhds_within_Iio_iff_exists_Ioo_subset' hl'
id   └─┘      └─┘     └────┘     └────────────────────────────────────────┘
src                   └────┘      └────────────────────────────────────────┘
typ  └─┘      └─┘     └────┘     └────────────────────────────────────────┘
doc                               └────────────────────────────────────────┘
730  
731  /-- A set is a neighborhood of `a` within `(-∞, a)` if and only if it contains an interval `[l, a)`
732  with `l < a`. -/
733  lemma mem_nhds_within_Iio_iff_exists_Ico_subset [no_bot_order α] [densely_ordered α]
id                                                    └──────────┘    └─────────────┘ 
src                                                   └──────────┘     └─────────────┘
typ                                                   └──────────┘    └─────────────┘ 
doc                                                   └──────────┘     └─────────────┘
734    {a : α} {s : set α} : s ∈ nhds_within a (Iio a) ↔ ∃l ∈ Iio a, Ico l a ⊆ s :=
id                 └─┘       └─────────┘   └─┘       └─┘  └─┘    
src                 └─┘         └─────────┘    └─┘         └─┘   └─┘     
typ                └─┘       └─────────┘   └─┘       └─┘  └─┘    
doc                              └─────────┘    └─┘           └─┘    └─┘
735  begin
st   └─────
736    convert @mem_nhds_within_Ioi_iff_exists_Ioc_subset (order_dual α) _ _ _ _ _ _ _,
id              └───────────────────────────────────────┘  └────────┘ 
src    └──────┘ └───────────────────────────────────────┘ └────────┘ └─────────────┘
typ    └──────┘ └───────────────────────────────────────┘ └────────┘└─────────────┘
doc    └──────┘ └───────────────────────────────────────┘ └────────┘ └─────────────┘
txt    └──────┘                                                      └─────────────┘
par    └──────┘                                                      └─────────────┘
pid                                                                 └─────────────┘
st   ────────────────────────────────────────────────────────────────────────────────┘└─
737    simp only [dual_Ioc], refl
id                └──────┘
src    └─────────┘└──────┘  └───┘
typ    └─────────┘└──────┘  └───┘
doc    └─────────┘          └───┘
txt    └─────────┘          └───┘
par    └─────────┘          └───┘
pid        └──┘└┘              
st   ─────────────────────┘└─────┘
738  end
st   └─┘
739  
740  lemma Ioo_mem_nhds_within_Iio {a b c : α} (h : b ∈ Ioc a c) :
id                                                   └─┘  
src                                                    └─┘
typ                                                  └─┘  
doc                                                     └─┘
741    Ioo a c ∈ nhds_within b (Iio b) :=
id     └─┘    └─────────┘   └─┘ 
src    └─┘      └─────────┘    └─┘
typ    └─┘    └─────────┘   └─┘ 
doc    └─┘       └─────────┘    └─┘
742  (mem_nhds_within_Iio_iff_exists_Ioo_subset' h.1).2 ⟨a, h.1, Ioo_subset_Ioo_right h.2⟩
id    └────────────────────────────────────────┘           └──────────────────┘ 
src   └────────────────────────────────────────┘              └──────────────────┘  
typ   └────────────────────────────────────────┘           └──────────────────┘ 
doc   └────────────────────────────────────────┘
743  
744  lemma Ioc_mem_nhds_within_Iio {a b c : α} (h : b ∈ Ioc a c) :
id                                                   └─┘  
src                                                    └─┘
typ                                                  └─┘  
doc                                                     └─┘
745    Ioc a c ∈ nhds_within b (Iio b) :=
id     └─┘    └─────────┘   └─┘ 
src    └─┘      └─────────┘    └─┘
typ    └─┘    └─────────┘   └─┘ 
doc    └─┘       └─────────┘    └─┘
746  mem_sets_of_superset (Ioo_mem_nhds_within_Iio h) Ioo_subset_Ioc_self
id   └──────────────────┘  └─────────────────────┘   └─────────────────┘
src  └──────────────────┘  └─────────────────────┘    └─────────────────┘
typ  └──────────────────┘  └─────────────────────┘   └─────────────────┘
747  
748  lemma Ico_mem_nhds_within_Iio {a b c : α} (h : b ∈ Ioc a c) :
id                                                   └─┘  
src                                                    └─┘
typ                                                  └─┘  
doc                                                     └─┘
749    Ico a c ∈ nhds_within b (Iio b) :=
id     └─┘    └─────────┘   └─┘ 
src    └─┘      └─────────┘    └─┘
typ    └─┘    └─────────┘   └─┘ 
doc    └─┘       └─────────┘    └─┘
750  mem_sets_of_superset (Ioo_mem_nhds_within_Iio h) Ioo_subset_Ico_self
id   └──────────────────┘  └─────────────────────┘   └─────────────────┘
src  └──────────────────┘  └─────────────────────┘    └─────────────────┘
typ  └──────────────────┘  └─────────────────────┘   └─────────────────┘
751  
752  lemma Icc_mem_nhds_within_Iio {a b c : α} (h : b ∈ Ioc a c) :
id                                                   └─┘  
src                                                    └─┘
typ                                                  └─┘  
doc                                                     └─┘
753    Icc a c ∈ nhds_within b (Iio b) :=
id     └─┘    └─────────┘   └─┘ 
src    └─┘      └─────────┘    └─┘
typ    └─┘    └─────────┘   └─┘ 
doc    └─┘       └─────────┘    └─┘
754  mem_sets_of_superset (Ioo_mem_nhds_within_Iio h) Ioo_subset_Icc_self
id   └──────────────────┘  └─────────────────────┘   └─────────────────┘
src  └──────────────────┘  └─────────────────────┘    └─────────────────┘
typ  └──────────────────┘  └─────────────────────┘   └─────────────────┘
755  
756  /-- A set is a neighborhood of `a` within `[a, +∞)` if and only if it contains an interval `[a, u)`
757  with `a < u`, provided `a` is not a top element. -/
758  lemma mem_nhds_within_Ici_iff_exists_Ico_subset' {a u' : α} {s : set α} (hu' : a < u') :
id                                                                   └─┘            └┘
src                                                                   └─┘             
typ                                                                  └─┘            └┘
759    s ∈ nhds_within a (Ici a) ↔ ∃u, a < u ∧ Ico a u ⊆ s :=
id       └─────────┘   └─┘         └─┘    
src       └─────────┘    └─┘             └─┘     
typ      └─────────┘   └─┘         └─┘    
doc        └─────────┘    └─┘                  └─┘
760  begin
st   └─────
761    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
762    { assume h,
src      └──────┘
typ      └──────┘
doc      └──────┘
txt      └──────┘
par      └──────┘
pid      └──────┘
st   ───┘└──────┘└─
763      rcases mem_nhds_within_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩,
id              └───────────────────────────────────────┘   
src      └─────┘└───────────────────────────────────────┘└─┘ └───────────────┘
typ      └─────┘└───────────────────────────────────────┘└─┘└───────────────┘
doc      └─────┘                                         └─┘ └───────────────┘
txt      └─────┘                                         └─┘ └───────────────┘
par      └─────┘                                         └─┘ └───────────────┘
pid                                                     └─┘ └───────────────┘
st   ────────────────────────────────────────────────────────────────────────┘└─
764      rcases exists_Ico_subset_of_mem_nhds va ⟨u', hu'⟩ with ⟨u, au, hu⟩,
id              └───────────────────────────┘ └┘  └┘  └─┘
src      └─────┘└───────────────────────────┘     └┘   └────────────────┘
typ      └─────┘└───────────────────────────┘└┘ └┘└┘└─┘└────────────────┘
doc      └─────┘                                  └┘   └────────────────┘
txt      └─────┘                                  └┘   └────────────────┘
par      └─────┘                                  └┘   └────────────────┘
pid                                              └┘   └────────────────┘
st   ─────────────────────────────────────────────────────────────────────┘└─
765      refine ⟨u, au, λx hx, _⟩,
id                 └┘
src      └─────┘  └┘  └┘ └──────┘
typ      └─────┘ └┘└┘└┘ └──────┘
doc      └─────┘  └┘  └┘ └──────┘
txt      └─────┘  └┘  └┘ └──────┘
par      └─────┘  └┘  └┘ └──────┘
pid              └┘  └┘ └──────┘
st   ───────────────────────────┘└─
766      refine hv ⟨_, hx.1⟩,
id              └┘     └┘
src      └─────┘   └─┘  └─┘
typ      └─────┘└┘ └─┘└┘└─┘
doc      └─────┘   └─┘  └─┘
txt      └─────┘   └─┘  └─┘
par      └─────┘   └─┘  └─┘
pid               └─┘  └─┘
st   ──────────────────────┘└─
767      exact hu hx },
id             └┘ └┘
src      └────┘    
typ      └────┘└┘└┘
doc      └────┘    
txt      └────┘    
par      └────┘    
pid               
st   ───────────────┘└┘
768    { rintros ⟨u, au, hu⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ──────────────────────┘└─
769      rw mem_nhds_within_iff_exists_mem_nhds_inter,
id          └───────────────────────────────────────┘
src      └─┘└───────────────────────────────────────┘
typ      └─┘└───────────────────────────────────────┘
doc      └─┘
txt      └─┘
par      └─┘
pid        
st   ───────────────────────────────────────────────┘└─
770      refine ⟨Iio u, mem_nhds_sets is_open_Iio au, _⟩,
id               └─┘   └───────────┘ └─────────┘ └┘
src      └─────┘ └─┘ └┘└───────────┘└─────────┘  └──┘
typ      └─────┘ └─┘└┘└───────────┘└─────────┘└┘└──┘
doc      └─────┘ └─┘ └┘                          └──┘
txt      └─────┘     └┘                          └──┘
par      └─────┘     └┘                          └──┘
pid                 └┘                          └──┘
st   ──────────────────────────────────────────────────┘└─
771      rwa [inter_comm, Ici_inter_Iio] }
id            └────────┘  └───────────┘
src      └───┘└────────┘└┘└───────────┘└┘
typ      └───┘└────────┘└┘└───────────┘└┘
doc      └───┘          └┘             └┘
txt      └───┘          └┘             └┘
par      └───┘          └┘             └┘
pid         └┘          └┘             
st   ──────────────────┘└─────────────┘└─
772  end
st   ──┘
773  
774  /-- A set is a neighborhood of `a` within `[a, +∞)` if and only if it contains an interval `[a, u)`
775  with `a < u`. -/
776  lemma mem_nhds_within_Ici_iff_exists_Ico_subset [no_top_order α] {a : α} {s : set α} :
id                                                    └──────────┘               └─┘ 
src                                                   └──────────┘                 └─┘
typ                                                   └──────────┘               └─┘ 
doc                                                   └──────────┘
777    s ∈ nhds_within a (Ici a) ↔ ∃u, a < u ∧ Ico a u ⊆ s :=
id       └─────────┘   └─┘         └─┘    
src       └─────────┘    └─┘             └─┘     
typ      └─────────┘   └─┘         └─┘    
doc        └─────────┘    └─┘                  └─┘
778  let ⟨u', hu'⟩ := no_top a in mem_nhds_within_Ici_iff_exists_Ico_subset' hu'
id   └─┘      └─┘     └────┘     └────────────────────────────────────────┘
src                   └────┘      └────────────────────────────────────────┘
typ  └─┘      └─┘     └────┘     └────────────────────────────────────────┘
doc                               └────────────────────────────────────────┘
779  
780  /-- A set is a neighborhood of `a` within `[a, +∞)` if and only if it contains an interval `[a, u]`
781  with `a < u`. -/
782  lemma mem_nhds_within_Ici_iff_exists_Icc_subset [no_top_order α] [densely_ordered α]
id                                                    └──────────┘    └─────────────┘ 
src                                                   └──────────┘     └─────────────┘
typ                                                   └──────────┘    └─────────────┘ 
doc                                                   └──────────┘     └─────────────┘
783    {a : α} {s : set α} : s ∈ nhds_within a (Ici a) ↔ ∃u, a < u ∧ Icc a u ⊆ s :=
id                 └─┘       └─────────┘   └─┘         └─┘    
src                 └─┘         └─────────┘    └─┘             └─┘     
typ                └─┘       └─────────┘   └─┘         └─┘    
doc                              └─────────┘    └─┘                  └─┘
784  begin
st   └─────
785    rw mem_nhds_within_Ici_iff_exists_Ico_subset,
id        └───────────────────────────────────────┘
src    └─┘└───────────────────────────────────────┘
typ    └─┘└───────────────────────────────────────┘
doc    └─┘└───────────────────────────────────────┘
txt    └─┘
par    └─┘
pid      
st   ─────────────────────────────────────────────┘└─
786    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
787    { rintros ⟨u, au, as⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ───┘└─────────────────┘└─
788      rcases dense au with ⟨v, hv⟩,
id              └───┘ └┘
src      └─────┘└───┘  └───────────┘
typ      └─────┘└───┘└┘└───────────┘
doc      └─────┘       └───────────┘
txt      └─────┘       └───────────┘
par      └─────┘       └───────────┘
pid                   └───────────┘
st   ───────────────────────────────┘└─
789      exact ⟨v, hv.1, λx hx, as ⟨hx.1, lt_of_le_of_lt hx.2 hv.2⟩⟩ },
id                             └┘        └────────────┘      └┘
src      └────┘  └┘  └──┘ └────┘     └──┘└────────────┘  └─┘  └───┘
typ      └────┘ └┘  └──┘ └────┘└┘   └──┘└────────────┘  └─┘└┘└───┘
doc      └────┘  └┘  └──┘ └────┘     └──┘                └─┘  └───┘
txt      └────┘  └┘  └──┘ └────┘     └──┘                └─┘  └───┘
par      └────┘  └┘  └──┘ └────┘     └──┘                └─┘  └───┘
pid             └┘  └──┘ └────┘     └──┘                └─┘  └──┘
st   ───────────────────────────────────────────────────────────────┘└┘
790    { rintros ⟨u, au, as⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ──────────────────────┘└─
791      exact ⟨u, au, subset.trans Ico_subset_Icc_self as⟩ }
id                └┘  └──────────┘ └─────────────────┘ └┘
src      └────┘  └┘  └┘└──────────┘└─────────────────┘  └┘
typ      └────┘ └┘└┘└┘└──────────┘└─────────────────┘└┘└┘
doc      └────┘  └┘  └┘                                 └┘
txt      └────┘  └┘  └┘                                 └┘
par      └────┘  └┘  └┘                                 └┘
pid             └┘  └┘                                 
st   ──────────────────────────────────────────────────────┘└─
792  end
st   ──┘
793  
794  /-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `(l, a]`
795  with `l < a`, provided `a` is not a bottom element. -/
796  lemma mem_nhds_within_Iic_iff_exists_Ioc_subset' {a l' : α} {s : set α} (hl' : l' < a) :
id                                                                   └─┘          └┘  
src                                                                   └─┘              
typ                                                                  └─┘          └┘  
797    s ∈ nhds_within a (Iic a) ↔ ∃l, l < a ∧ Ioc l a ⊆ s :=
id       └─────────┘   └─┘         └─┘    
src       └─────────┘    └─┘             └─┘     
typ      └─────────┘   └─┘         └─┘    
doc        └─────────┘    └─┘                  └─┘
798  begin
st   └─────
799    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
800    { assume h,
src      └──────┘
typ      └──────┘
doc      └──────┘
txt      └──────┘
par      └──────┘
pid      └──────┘
st   ───┘└──────┘└─
801      rcases mem_nhds_within_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩,
id              └───────────────────────────────────────┘   
src      └─────┘└───────────────────────────────────────┘└─┘ └───────────────┘
typ      └─────┘└───────────────────────────────────────┘└─┘└───────────────┘
doc      └─────┘                                         └─┘ └───────────────┘
txt      └─────┘                                         └─┘ └───────────────┘
par      └─────┘                                         └─┘ └───────────────┘
pid                                                     └─┘ └───────────────┘
st   ────────────────────────────────────────────────────────────────────────┘└─
802      rcases exists_Ioc_subset_of_mem_nhds va ⟨l', hl'⟩ with ⟨l, la, hl⟩,
id              └───────────────────────────┘ └┘  └┘  └─┘
src      └─────┘└───────────────────────────┘     └┘   └────────────────┘
typ      └─────┘└───────────────────────────┘└┘ └┘└┘└─┘└────────────────┘
doc      └─────┘                                  └┘   └────────────────┘
txt      └─────┘                                  └┘   └────────────────┘
par      └─────┘                                  └┘   └────────────────┘
pid                                              └┘   └────────────────┘
st   ─────────────────────────────────────────────────────────────────────┘└─
803      refine ⟨l, la, λx hx, _⟩,
id                 └┘
src      └─────┘  └┘  └┘ └──────┘
typ      └─────┘ └┘└┘└┘ └──────┘
doc      └─────┘  └┘  └┘ └──────┘
txt      └─────┘  └┘  └┘ └──────┘
par      └─────┘  └┘  └┘ └──────┘
pid              └┘  └┘ └──────┘
st   ───────────────────────────┘└─
804      refine hv ⟨_, hx.2⟩,
id              └┘     └┘
src      └─────┘   └─┘  └─┘
typ      └─────┘└┘ └─┘└┘└─┘
doc      └─────┘   └─┘  └─┘
txt      └─────┘   └─┘  └─┘
par      └─────┘   └─┘  └─┘
pid               └─┘  └─┘
st   ──────────────────────┘└─
805      exact hl hx },
id             └┘ └┘
src      └────┘    
typ      └────┘└┘└┘
doc      └────┘    
txt      └────┘    
par      └────┘    
pid               
st   ───────────────┘└┘
806    { rintros ⟨l, la, ha⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ──────────────────────┘└─
807      rw mem_nhds_within_iff_exists_mem_nhds_inter,
id          └───────────────────────────────────────┘
src      └─┘└───────────────────────────────────────┘
typ      └─┘└───────────────────────────────────────┘
doc      └─┘
txt      └─┘
par      └─┘
pid        
st   ───────────────────────────────────────────────┘└─
808      refine ⟨Ioi l, mem_nhds_sets is_open_Ioi la, _⟩,
id               └─┘   └───────────┘ └─────────┘ └┘
src      └─────┘ └─┘ └┘└───────────┘└─────────┘  └──┘
typ      └─────┘ └─┘└┘└───────────┘└─────────┘└┘└──┘
doc      └─────┘ └─┘ └┘                          └──┘
txt      └─────┘     └┘                          └──┘
par      └─────┘     └┘                          └──┘
pid                 └┘                          └──┘
st   ──────────────────────────────────────────────────┘└─
809      rwa [Ioi_inter_Iic] }
id            └───────────┘
src      └───┘└───────────┘└┘
typ      └───┘└───────────┘└┘
doc      └───┘             └┘
txt      └───┘             └┘
par      └───┘             └┘
pid         └┘             
st   ─────────────────────┘└─
810  end
st   ──┘
811  
812  /-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `(l, a]`
813  with `l < a`. -/
814  lemma mem_nhds_within_Iic_iff_exists_Ioc_subset [no_bot_order α] {a : α} {s : set α} :
id                                                    └──────────┘               └─┘ 
src                                                   └──────────┘                 └─┘
typ                                                   └──────────┘               └─┘ 
doc                                                   └──────────┘
815    s ∈ nhds_within a (Iic a) ↔ ∃l, l < a ∧ Ioc l a ⊆ s :=
id       └─────────┘   └─┘         └─┘    
src       └─────────┘    └─┘             └─┘     
typ      └─────────┘   └─┘         └─┘    
doc        └─────────┘    └─┘                  └─┘
816  let ⟨l', hl'⟩ := no_bot a in mem_nhds_within_Iic_iff_exists_Ioc_subset' hl'
id   └─┘      └─┘     └────┘     └────────────────────────────────────────┘
src                   └────┘      └────────────────────────────────────────┘
typ  └─┘      └─┘     └────┘     └────────────────────────────────────────┘
doc                               └────────────────────────────────────────┘
817  
818  /-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `[l, a]`
819  with `l < a`. -/
820  lemma mem_nhds_within_Iic_iff_exists_Icc_subset [no_bot_order α] [densely_ordered α]
id                                                    └──────────┘    └─────────────┘ 
src                                                   └──────────┘     └─────────────┘
typ                                                   └──────────┘    └─────────────┘ 
doc                                                   └──────────┘     └─────────────┘
821    {a : α} {s : set α} : s ∈ nhds_within a (Iic a) ↔ ∃l, l < a ∧ Icc l a ⊆ s :=
id                 └─┘       └─────────┘   └─┘         └─┘    
src                 └─┘         └─────────┘    └─┘             └─┘     
typ                └─┘       └─────────┘   └─┘         └─┘    
doc                              └─────────┘    └─┘                  └─┘
822  begin
st   └─────
823    rw mem_nhds_within_Iic_iff_exists_Ioc_subset,
id        └───────────────────────────────────────┘
src    └─┘└───────────────────────────────────────┘
typ    └─┘└───────────────────────────────────────┘
doc    └─┘└───────────────────────────────────────┘
txt    └─┘
par    └─┘
pid      
st   ─────────────────────────────────────────────┘└─
824    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
825    { rintros ⟨l, la, as⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ───┘└─────────────────┘└─
826      rcases dense la with ⟨v, hv⟩,
id              └───┘ └┘
src      └─────┘└───┘  └───────────┘
typ      └─────┘└───┘└┘└───────────┘
doc      └─────┘       └───────────┘
txt      └─────┘       └───────────┘
par      └─────┘       └───────────┘
pid                   └───────────┘
st   ───────────────────────────────┘└─
827      refine ⟨v, hv.2, λx hx, as ⟨lt_of_lt_of_le hv.1 hx.1, hx.2⟩⟩, },
id                              └┘  └────────────┘ └┘
src      └─────┘  └┘  └──┘ └────┘   └────────────┘  └─┘  └──┘  └──┘
typ      └─────┘ └┘  └──┘ └────┘└┘ └────────────┘└┘└─┘  └──┘  └──┘
doc      └─────┘  └┘  └──┘ └────┘                   └─┘  └──┘  └──┘
txt      └─────┘  └┘  └──┘ └────┘                   └─┘  └──┘  └──┘
par      └─────┘  └┘  └──┘ └────┘                   └─┘  └──┘  └──┘
pid              └┘  └──┘ └────┘                   └─┘  └──┘  └──┘
st   ───────────────────────────────────────────────────────────────┘└──┘
828    { rintros ⟨l, la, as⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ──────────────────────┘└─
829      exact ⟨l, la, subset.trans Ioc_subset_Icc_self as⟩ }
id                └┘  └──────────┘ └─────────────────┘ └┘
src      └────┘  └┘  └┘└──────────┘└─────────────────┘  └┘
typ      └────┘ └┘└┘└┘└──────────┘└─────────────────┘└┘└┘
doc      └────┘  └┘  └┘                                 └┘
txt      └────┘  └┘  └┘                                 └┘
par      └────┘  └┘  └┘                                 └┘
pid             └┘  └┘                                 
st   ──────────────────────────────────────────────────────┘└─
830  end
st   ──┘
831  
832  end linear_order
833  
834  lemma preimage_neg [add_group α] : preimage (has_neg.neg : α → α) = image (has_neg.neg : α → α) :=
id                       └───────┘     └──────┘  └─────────┘         └───┘  └─────────┘      
src                      └───────┘      └──────┘  └─────────┘           └───┘  └─────────┘
typ                      └───────┘     └──────┘  └─────────┘         └───┘  └─────────┘      
doc                                     └──────┘
835  (image_eq_preimage_of_inverse neg_neg neg_neg).symm
id    └──────────────────────────┘ └─────┘ └─────┘ └──┘
src   └──────────────────────────┘ └─────┘ └─────┘ └──┘
typ   └──────────────────────────┘ └─────┘ └─────┘ └──┘
836  
837  lemma filter.map_neg [add_group α] : map (has_neg.neg : α → α) = comap (has_neg.neg : α → α) :=
id                         └───────┘     └─┘  └─────────┘         └───┘  └─────────┘      
src                        └───────┘      └─┘  └─────────┘           └───┘  └─────────┘
typ                        └───────┘     └─┘  └─────────┘         └───┘  └─────────┘      
doc                                       └─┘                         └───┘
838  funext $ assume f, map_eq_comap_of_inverse (funext neg_neg) (funext neg_neg)
id   └────┘            └─────────────────────┘  └────┘ └─────┘   └────┘ └─────┘
src  └────┘             └─────────────────────┘  └────┘ └─────┘   └────┘ └─────┘
typ  └────┘            └─────────────────────┘  └────┘ └─────┘   └────┘ └─────┘
839  
840  section topological_add_group
841  
842  variables [topological_space α] [ordered_comm_group α] [topological_add_group α]
id              └───────────────┘     └────────────────┘     └───────────────────┘
src             └───────────────┘     └────────────────┘     └───────────────────┘
typ             └───────────────┘     └────────────────┘     └───────────────────┘
doc             └───────────────┘                            └───────────────────┘
843  
844  lemma neg_preimage_closure {s : set α} : (λr:α, -r) ⁻¹' closure s = closure ((λr:α, -r) '' s) :=
id                                   └─┘             └─┘ └─────┘   └─────┘          └┘ 
src                                  └─┘                └─┘ └─────┘    └─────┘            └┘
typ                                  └─┘             └─┘ └─────┘   └─────┘          └┘ 
doc                                                      └─┘ └─────┘     └─────┘
845  have (λr:α, -r) ∘ (λr:α, -r) = id, from funext neg_neg,
id                          └┘       └────┘ └─────┘
src                             └┘       └────┘ └─────┘
typ                         └┘       └────┘ └─────┘
846  by rw [preimage_neg]; exact
id          └──────────┘
src     └──┘└──────────┘  └─────
typ     └──┘└──────────┘  └─────
doc     └──┘              └─────
txt     └──┘              └─────
par     └──┘              └─────
pid       └┘                   
st     └───────────────┘└───────
847    (subset.antisymm (image_closure_subset_closure_image continuous_neg) $
id      └─────────────┘
src  ─┘ └─────────────┘                                                 └┘ 
typ  ─┘ └─────────────┘                                                 └┘ 
doc  ─┘                                                                 └┘ 
txt  ─┘                                                                 └┘ 
par  ─┘                                                                 └┘ 
pid  ─┘                                                                 └┘ 
st   ─────────────────────────────────────────────────────────────────────────
848      calc closure ((λ (r : α), -r) '' s) = (λr, -r) '' ((λr, -r) '' closure ((λ (r : α), -r) '' s)) :
id                                    └┘                               └─────┘                    
src  ───┘              └────┘ └─┘ └┘└┘ └┘   └─┘  └┘     └─┘  └┘  └─────┘   └────┘ └─┘  └┘   └────
typ  ───┘              └────┘ └─┘ └┘└┘ └┘   └─┘  └┘     └─┘  └┘  └─────┘   └────┘└─┘  └┘  └────
doc  ───┘              └────┘ └─┘  └┘   └┘   └─┘  └┘     └─┘  └┘  └─────┘   └────┘ └─┘  └┘   └────
txt  ───┘              └────┘ └─┘  └┘   └┘   └─┘  └┘     └─┘  └┘            └────┘ └─┘  └┘   └────
par  ───┘              └────┘ └─┘  └┘   └┘   └─┘  └┘     └─┘  └┘            └────┘ └─┘  └┘   └────
pid  ───┘              └────┘ └─┘  └┘   └┘   └─┘  └┘     └─┘  └┘            └────┘ └─┘  └┘   └────
st   ─────────────────────────────────────────────────────────────────────────────────────────────────────
849          by rw [←image_comp, this, image_id]
id                   └────────┘  └──┘  └──────┘
src  ───────┘  └───┘└────────┘└┘    └┘└──────┘└─
typ  ───────┘  └───┘└────────┘└┘└──┘└┘└──────┘└─
doc  ───────┘  └───┘          └┘    └┘        └─
txt  ───────┘  └───┘          └┘    └┘        └─
par  ───────┘  └───┘          └┘    └┘        └─
pid  ───────┘  └────┘          └┘    └┘        └─
st   ─────────┘└──────────────┘└────┘└────────┘
850        ... ⊆ (λr, -r) '' closure ((λr, -r) '' ((λ (r : α), -r) '' s)) :
src  ─────┘└──┘   └─┘  └┘            └─┘  └┘     └────┘ └─┘  └┘   └────
typ  ─────┘└──┘   └─┘  └┘            └─┘  └┘     └────┘ └─┘  └┘   └────
doc  ─────┘└──┘   └─┘  └┘            └─┘  └┘     └────┘ └─┘  └┘   └────
txt  ─────┘└──┘   └─┘  └┘            └─┘  └┘     └────┘ └─┘  └┘   └────
par  ─────┘└──┘   └─┘  └┘            └─┘  └┘     └────┘ └─┘  └┘   └────
pid  ─────────┘   └─┘  └┘            └─┘  └┘     └────┘ └─┘  └┘   └────
st   ─────┘└────────────────────────────────────────────────────────────────
851          mono_image $ image_closure_subset_closure_image continuous_neg
id           └────────┘   └────────────────────────────────┘ └────────────┘
src  ───────┘└────────┘ └────────────────────────────────┘└────────────┘
typ  ───────┘└────────┘ └────────────────────────────────┘└────────────┘
doc  ───────┘                                                           
txt  ───────┘                                                           
par  ───────┘                                                           
pid  ───────┘                                                           
st   ───────────────────────────────────────────────────────────────────────
852        ... = _ : by rw [←image_comp, this, image_id])
id                           └────────┘  └──┘  └──────┘
src  ─────────┘ └───┘  └───┘└────────┘└┘    └┘└──────┘└─
typ  ─────────┘ └───┘  └───┘└────────┘└┘└──┘└┘└──────┘└─
doc  ─────────┘ └───┘  └───┘          └┘    └┘        └─
txt  ─────────┘ └───┘  └───┘          └┘    └┘        └─
par  ─────────┘ └───┘  └───┘          └┘    └┘        └─
pid  ─────────┘ └───┘  └────┘          └┘    └┘        └┘
st   ─────────────────┘└──────────────┘└────┘└────────┘└─
853  
src  
typ  
doc  
txt  
par  
pid  
st   
854  end topological_add_group
855  
856  section order_topology
857  
858  variables [topological_space α] [topological_space β]
id              └───────────────┘     └───────────────┘
src             └───────────────┘     └───────────────┘
typ             └───────────────┘     └───────────────┘
doc             └───────────────┘     └───────────────┘
859    [linear_order α] [linear_order β] [order_topology α] [order_topology β]
id      └──────────┘     └──────────┘     └────────────┘     └────────────┘
src     └──────────┘     └──────────┘     └────────────┘     └────────────┘
typ     └──────────┘     └──────────┘     └────────────┘     └────────────┘
doc                                       └────────────┘     └────────────┘
860  
861  lemma nhds_principal_ne_bot_of_is_lub {a : α} {s : set α} (ha : is_lub s a) (hs : s.nonempty) :
id                                                     └─┘         └────┘          └───────┘
src                                                     └─┘          └────┘             └───────┘
typ                                                    └─┘         └────┘          └───────┘
doc                                                                  └────┘             └───────┘
862    𝓝 a ⊓ principal s ≠ ⊥ :=
id        └───────┘   
src        └───────┘    
typ       └───────┘   
doc         └───────┘
863  let ⟨a', ha'⟩ := hs in
id   └─┘  └┘          └┘
typ  └─┘  └┘          └┘
864  forall_sets_nonempty_iff_ne_bot.mp $ assume t ht,
id   └─────────────────────────────┘└─┘           └┘
src  └─────────────────────────────┘└─┘
typ  └─────────────────────────────┘└─┘           └┘
865    let ⟨t₁, ht₁, t₂, ht₂, ht⟩ := mem_inf_sets.mp ht in
id     └─┘  └┘  └─┘  └┘  └─┘  └┘     └──────────┘└─┘ └┘
src                                  └──────────┘└─┘
typ    └─┘  └┘  └─┘  └┘  └─┘  └┘     └──────────┘└─┘ └┘
866    by_cases
id     └──────┘
src    └──────┘
typ    └──────┘
867      (assume h : a = a',
id                    
src                    
typ                   
868        have a ∈ t₁, from mem_of_nhds ht₁,
id                         └─────────┘
src                         └─────────┘
typ                        └─────────┘
869        have a ∈ t₂, from ht₂ $ by rwa [h],
id                                       
src                                  └───┘ 
typ                                 └───┘
doc                                   └───┘ 
txt                                   └───┘ 
par                                   └───┘ 
pid                                      └┘ 
st                                   └─────┘
870        ⟨a, ht ⟨‹a ∈ t₁›, ‹a ∈ t₂›⟩⟩)
id                          
src                            
typ                         
doc                              
871      (assume : a ≠ a',
id                  
src                  
typ                 
872        have a' < a, from lt_of_le_of_ne (ha.left ‹a' ∈ s›) this.symm,
id                         └────────────┘  └┘└───┘       └──┘└───┘
src                         └────────────┘    └───┘            └───┘
typ                        └────────────┘  └┘└───┘       └──┘└───┘
doc                                                        
873        let ⟨l, hl, hlt₁⟩ := exists_Ioc_subset_of_mem_nhds ht₁ ⟨a', this⟩ in
id         └─┘        └──┘     └───────────────────────────┘          └──┘
src                             └───────────────────────────┘
typ        └─┘        └──┘     └───────────────────────────┘          └──┘
874        have ∃a'∈s, l < a',
id              └┘     └┘
src                    
typ             └┘     └┘
875          from classical.by_contradiction $ assume : ¬ ∃a'∈s, l < a',
id                └────────────────────────┘             └┘     └┘
src               └────────────────────────┘                    
typ               └────────────────────────┘             └┘     └┘
876            have ∀a'∈s, a' ≤ l, from assume a ha, not_lt.1 $ assume ha', this ⟨a, ha, ha'⟩,
id                   └┘   └┘                  └┘  └────┘           └─┘  └──┘    └┘  └─┘
src                                                 └────┘
typ                  └┘   └┘                  └┘  └────┘           └─┘  └──┘    └┘  └─┘
877            have ¬ l < a, from not_lt.2 $ ha.right this,
id                             └────┘    └┘└────┘ └──┘
src                             └────┘      └────┘
typ                            └────┘    └┘└────┘ └──┘
878            this ‹l < a›,
id             └──┘    
src                     
typ            └──┘    
doc                      
879        let ⟨a', ha', ha'l⟩ := this in
id         └─┘  └┘  └─┘           └──┘
typ        └─┘  └┘  └─┘           └──┘
880        have a' ∈ t₁, from hlt₁ ⟨‹l < a'›, ha.left ha'⟩,
id                                        └┘└───┘
src                                         └───┘
typ                                       └┘└───┘
doc                                       
881        ⟨a', ht ⟨‹a' ∈ t₁›, ht₂ ‹a' ∈ s›⟩⟩)
id                                  
src                                  
typ                                 
doc                                    
882  
883  lemma nhds_principal_ne_bot_of_is_glb : ∀ {a : α} {s : set α}, is_glb s a → s.nonempty →
id                                                         └─┘    └────┘     └───────┘
src                                                         └─┘     └────┘        └───────┘
typ                                                        └─┘    └────┘     └───────┘
doc                                                                 └────┘        └───────┘
884    𝓝 a ⊓ principal s ≠ ⊥ :=
id        └───────┘   
src        └───────┘    
typ       └───────┘   
doc         └───────┘
885  @nhds_principal_ne_bot_of_is_lub (order_dual α) _ _ _
id    └─────────────────────────────┘  └────────┘ 
src   └─────────────────────────────┘  └────────┘
typ   └─────────────────────────────┘  └────────┘ 
doc                                    └────────┘
886  
887  lemma is_lub_of_mem_nhds {s : set α} {a : α} {f : filter α}
id                                 └─┘               └────┘ 
src                                └─┘                 └────┘
typ                                └─┘               └────┘ 
888    (hsa : a ∈ upper_bounds s) (hsf : s ∈ f) (hfa : f ⊓ 𝓝 a ≠ ⊥) : is_lub s a :=
id              └──────────┘                              └────┘  
src              └──────────┘                                   └────┘
typ             └──────────┘                              └────┘  
doc               └──────────┘                                       └────┘
889  ⟨hsa, assume b hb,
id    └─┘          └┘
typ   └─┘          └┘
890    not_lt.1 $ assume hba,
id     └────┘           └─┘
src    └────┘
typ    └────┘           └─┘
891    have s ∩ {a | b < a} ∈ f ⊓ 𝓝 a,
id                       
src                          
typ                      
doc                               
892      from inter_mem_inf_sets hsf (mem_nhds_sets (is_open_lt' _) hba),
id            └────────────────┘ └─┘  └───────────┘  └─────────┘    └─┘
src           └────────────────┘      └───────────┘  └─────────┘
typ           └────────────────┘ └─┘  └───────────┘  └─────────┘    └─┘
893    let ⟨x, ⟨hxs, hxb⟩⟩ := nonempty_of_mem_sets hfa this in
id     └─┘      └─┘  └─┘      └──────────────────┘ └─┘ └──┘
src                           └──────────────────┘
typ    └─┘      └─┘  └─┘      └──────────────────┘ └─┘ └──┘
894    have b < b, from lt_of_lt_of_le hxb $ hb hxs,
id                   └────────────┘       └┘
src                    └────────────┘
typ                  └────────────┘       └┘
895    lt_irrefl b this⟩
id     └───────┘  └──┘
src    └───────┘
typ    └───────┘  └──┘
896  
897  lemma is_glb_of_mem_nhds : ∀ {s : set α} {a : α} {f : filter α},
id                                     └─┘               └────┘ 
src                                    └─┘                 └────┘
typ                                    └─┘               └────┘ 
898    a ∈ lower_bounds s → s ∈ f → f ⊓ 𝓝 a ≠ ⊥ → is_glb s a :=
id       └──────────┘                 └────┘  
src       └──────────┘                      └────┘
typ      └──────────┘                 └────┘  
doc        └──────────┘                          └────┘
899  @is_lub_of_mem_nhds (order_dual α) _ _ _
id    └────────────────┘  └────────┘ 
src   └────────────────┘  └────────┘
typ   └────────────────┘  └────────┘ 
doc                       └────────┘
900  
901  lemma is_lub_of_is_lub_of_tendsto {f : α → β} {s : set α} {a : α} {b : β}
id                                                    └─┘               
src                                                     └─┘
typ                                                   └─┘               
902    (hf : ∀x∈s, ∀y∈s, x ≤ y → f x ≤ f y) (ha : is_lub s a) (hs : s.nonempty)
id                                    └────┘          └───────┘
src                                             └────┘             └───────┘
typ                                   └────┘          └───────┘
doc                                               └────┘             └───────┘
903    (hb : tendsto f (𝓝 a ⊓ principal s) (𝓝 b)) : is_lub (f '' s) b :=
id           └─────┘      └───────┘          └────┘   └┘   
src          └─────┘        └───────┘            └────┘    └┘
typ          └─────┘      └───────┘          └────┘   └┘   
doc          └─────┘         └───────┘            └────┘
904  have hnbot : (𝓝 a ⊓ principal s) ≠ ⊥, from nhds_principal_ne_bot_of_is_lub ha hs,
id                    └───────┘           └─────────────────────────────┘ └┘ └┘
src                    └───────┘            └─────────────────────────────┘
typ                   └───────┘           └─────────────────────────────┘ └┘ └┘
doc                     └───────┘
905  have ∀a'∈s, ¬ b < f a',
id         └┘       └┘
src                 
typ        └┘       └┘
906    from assume a' ha' h,
id                 └┘ └─┘ 
typ                └┘ └─┘ 
907    have ∀ᶠ x in 𝓝 b, x < f a', from mem_nhds_sets (is_open_gt' _) h,
id          └┘  └┘      └┘       └───────────┘  └─────────┘    
src         └┘   └┘                  └───────────┘  └─────────┘
typ         └┘  └┘      └┘       └───────────┘  └─────────┘    
doc         └┘   └┘   
908    let ⟨t₁, ht₁, t₂, ht₂, hs⟩ := mem_inf_sets.mp (hb this) in
id     └─┘  └┘  └─┘  └┘  └─┘  └┘     └──────────┘└─┘  └┘ └──┘
src                                  └──────────┘└─┘
typ    └─┘  └┘  └─┘  └┘  └─┘  └┘     └──────────┘└─┘  └┘ └──┘
909    by_cases
id     └──────┘
src    └──────┘
typ    └──────┘
910      (assume h : a = a',
id                     └┘
src                    
typ                    └┘
911        have a ∈ t₁ ∩ t₂, from ⟨mem_of_nhds ht₁, ht₂ $ by rwa [h]⟩,
id                              └─────────┘                    
src                              └─────────┘               └───┘ 
typ                             └─────────┘               └───┘
doc                                                          └───┘ 
txt                                                          └───┘ 
par                                                          └───┘ 
pid                                                             └┘ 
st                                                          └─────┘
912        have f a < f a', from hs this,
id                  └┘          └──┘
src                 
typ                 └┘          └──┘
913        lt_irrefl (f a') $ by rwa [h] at this)
id         └───────┘   └┘            
src        └───────┘             └───┘ └───────┘
typ        └───────┘   └┘       └───┘└───────┘
doc                              └───┘ └───────┘
txt                              └───┘ └───────┘
par                              └───┘ └───────┘
pid                                 └┘ └──────┘
st                              └─────┘└──────┘
914      (assume h : a ≠ a',
id                     └┘
src                    
typ                    └┘
915        have a' < a, from lt_of_le_of_ne (ha.left ha') h.symm,
id              └┘         └────────────┘  └┘└───┘ └─┘  └───┘
src                         └────────────┘    └───┘       └───┘
typ             └┘         └────────────┘  └┘└───┘ └─┘  └───┘
916        have {x | a' < x} ∈ 𝓝 a, from mem_nhds_sets (is_open_lt' _) this,
id                 └┘             └───────────┘  └─────────┘    └──┘
src                                  └───────────┘  └─────────┘
typ                └┘             └───────────┘  └─────────┘    └──┘
doc                            
917        have {x | a' < x} ∩ t₁ ∈ 𝓝 a, from inter_mem_sets this ht₁,
id                 └┘                 └────────────┘ └──┘
src                                      └────────────┘
typ                └┘                 └────────────┘ └──┘
doc                                 
918        have ({x | a' < x} ∩ t₁) ∩ s ∈ 𝓝 a ⊓ principal s,
id                  └┘               └───────┘ 
src                                      └───────┘
typ                 └┘               └───────┘ 
doc                                            └───────┘
919          from inter_mem_inf_sets this (subset.refl s),
id                └────────────────┘ └──┘  └─────────┘ 
src               └────────────────┘       └─────────┘
typ               └────────────────┘ └──┘  └─────────┘ 
920        let ⟨x, ⟨hx₁, hx₂⟩, hx₃⟩ := nonempty_of_mem_sets hnbot this in
id         └─┘     └─┘  └─┘   └─┘     └──────────────────┘ └───┘ └──┘
src                                    └──────────────────┘
typ        └─┘     └─┘  └─┘   └─┘     └──────────────────┘ └───┘ └──┘
921        have hxa' : f x < f a', from hs ⟨hx₂, ht₂ hx₃⟩,
id                          └┘
src                        
typ                         └┘
922        have ha'x : f a' ≤ f x, from hf _ ha' _ hx₃ $ le_of_lt hx₁,
id                      └┘           └┘   └─┘         └──────┘
src                                                     └──────┘
typ                     └┘           └┘   └─┘         └──────┘
923        lt_irrefl _ (lt_of_le_of_lt ha'x hxa')),
id         └───────┘    └────────────┘ └──┘ └──┘
src        └───────┘    └────────────┘
typ        └───────┘    └────────────┘ └──┘ └──┘
924  and.intro
id   └───────┘
src  └───────┘
typ  └───────┘
925    (assume b' ⟨a', ha', h_eq⟩, h_eq ▸ not_lt.1 $ this _ ha')
id             └┘     └─┘  └──┘         └────┘    └──┘
src                                      └────┘
typ            └┘     └─┘  └──┘         └────┘    └──┘
926    (assume b' hb', le_of_tendsto hnbot hb $
id             └┘ └─┘  └───────────┘ └───┘ └┘
src                    └───────────┘
typ            └┘ └─┘  └───────────┘ └───┘ └┘
927        mem_inf_sets_of_right $ assume x hx, hb' $ mem_image_of_mem _ hx)
id         └───────────────────┘           └┘  └─┘   └──────────────┘   └┘
src        └───────────────────┘                      └──────────────┘
typ        └───────────────────┘           └┘  └─┘   └──────────────┘   └┘
928  
929  lemma is_glb_of_is_glb_of_tendsto {f : α → β} {s : set α} {a : α} {b : β}
id                                                    └─┘               
src                                                     └─┘
typ                                                   └─┘               
930    (hf : ∀x∈s, ∀y∈s, x ≤ y → f x ≤ f y) : is_glb s a → s.nonempty →
id                                └────┘     └───────┘
src                                         └────┘        └───────┘
typ                               └────┘     └───────┘
doc                                           └────┘        └───────┘
931    tendsto f (𝓝 a ⊓ principal s) (𝓝 b) → is_glb (f '' s) b :=
id     └─────┘      └───────┘         └────┘   └┘   
src    └─────┘        └───────┘           └────┘    └┘
typ    └─────┘      └───────┘         └────┘   └┘   
doc    └─────┘         └───────┘           └────┘
932  @is_lub_of_is_lub_of_tendsto (order_dual α) (order_dual β) _ _ _ _ _ _ f s a b
id    └─────────────────────────┘  └────────┘    └────────┘                  
src   └─────────────────────────┘  └────────┘     └────────┘
typ   └─────────────────────────┘  └────────┘    └────────┘                  
doc                                └────────┘     └────────┘
933    (λ x hx y hy, hf y hy x hx)
id         └┘  └┘  └┘  └┘  └┘
typ        └┘  └┘  └┘  └┘  └┘
934  
935  lemma is_glb_of_is_lub_of_tendsto : ∀ {f : α → β} {s : set α} {a : α} {b : β},
id                                                       └─┘               
src                                                         └─┘
typ                                                      └─┘               
936    (∀x∈s, ∀y∈s, x ≤ y → f y ≤ f x) → is_lub s a → s.nonempty →
id                           └────┘     └───────┘
src                                    └────┘        └───────┘
typ                          └────┘     └───────┘
doc                                      └────┘        └───────┘
937    tendsto f (𝓝 a ⊓ principal s) (𝓝 b) → is_glb (f '' s) b :=
id     └─────┘      └───────┘         └────┘   └┘   
src    └─────┘        └───────┘           └────┘    └┘
typ    └─────┘      └───────┘         └────┘   └┘   
doc    └─────┘         └───────┘           └────┘
938  @is_lub_of_is_lub_of_tendsto α (order_dual β) _ _ _ _ _ _
id    └─────────────────────────┘   └────────┘ 
src   └─────────────────────────┘    └────────┘
typ   └─────────────────────────┘   └────────┘ 
doc                                  └────────┘
939  
940  lemma is_lub_of_is_glb_of_tendsto : ∀ {f : α → β} {s : set α} {a : α} {b : β},
id                                                       └─┘               
src                                                         └─┘
typ                                                      └─┘               
941    (∀x∈s, ∀y∈s, x ≤ y → f y ≤ f x) → is_glb s a → s.nonempty →
id                           └────┘     └───────┘
src                                    └────┘        └───────┘
typ                          └────┘     └───────┘
doc                                      └────┘        └───────┘
942    tendsto f (𝓝 a ⊓ principal s) (𝓝 b) → is_lub (f '' s) b :=
id     └─────┘      └───────┘         └────┘   └┘   
src    └─────┘        └───────┘           └────┘    └┘
typ    └─────┘      └───────┘         └────┘   └┘   
doc    └─────┘         └───────┘           └────┘
943  @is_glb_of_is_glb_of_tendsto α (order_dual β) _ _ _ _ _ _
id    └─────────────────────────┘   └────────┘ 
src   └─────────────────────────┘    └────────┘
typ   └─────────────────────────┘   └────────┘ 
doc                                  └────────┘
944  
945  lemma mem_closure_of_is_lub {a : α} {s : set α} (ha : is_lub s a) (hs : s.nonempty) : a ∈ closure s :=
id                                           └─┘         └────┘          └───────┘      └─────┘ 
src                                           └─┘          └────┘             └───────┘       └─────┘
typ                                          └─┘         └────┘          └───────┘      └─────┘ 
doc                                                        └────┘             └───────┘        └─────┘
946  by rw closure_eq_nhds; exact nhds_principal_ne_bot_of_is_lub ha hs
id         └─────────────┘        └─────────────────────────────┘ └┘ └┘
src     └─┘└─────────────┘  └────┘└─────────────────────────────┘    
typ     └─┘└─────────────┘  └────┘└─────────────────────────────┘└┘└┘
doc     └─┘                 └────┘                                   
txt     └─┘                 └────┘                                   
par     └─┘                 └────┘                                   
pid                                                                
st     └────────────────────────────────────────────────────────────────
947  
src  
typ  
doc  
txt  
par  
pid  
st   
948  lemma mem_of_is_lub_of_is_closed {a : α} {s : set α} (ha : is_lub s a) (hs : s.nonempty) (sc : is_closed s) : a ∈ s :=
id                                                └─┘         └────┘          └───────┘        └───────┘       
src                                                └─┘          └────┘             └───────┘        └───────┘        
typ                                               └─┘         └────┘          └───────┘        └───────┘       
doc                                                             └────┘             └───────┘        └───────┘
949  by rw ←closure_eq_of_is_closed sc; exact mem_closure_of_is_lub ha hs
id          └─────────────────────┘ └┘        └───────────────────┘ └┘ └┘
src     └──┘└─────────────────────┘    └────┘└───────────────────┘    
typ     └──┘└─────────────────────┘└┘  └────┘└───────────────────┘└┘└┘
doc     └──┘                           └────┘                         
txt     └──┘                           └────┘                         
par     └──┘                           └────┘                         
pid       └┘                                                         
st     └──────────────────────────────────────────────────────────────────
950  
src  
typ  
doc  
txt  
par  
pid  
st   
951  lemma mem_closure_of_is_glb {a : α} {s : set α} (ha : is_glb s a) (hs : s.nonempty) : a ∈ closure s :=
id                                           └─┘         └────┘          └───────┘      └─────┘ 
src                                           └─┘          └────┘             └───────┘       └─────┘
typ                                          └─┘         └────┘          └───────┘      └─────┘ 
doc                                                        └────┘             └───────┘        └─────┘
952  by rw closure_eq_nhds; exact nhds_principal_ne_bot_of_is_glb ha hs
id         └─────────────┘        └─────────────────────────────┘ └┘ └┘
src     └─┘└─────────────┘  └────┘└─────────────────────────────┘    
typ     └─┘└─────────────┘  └────┘└─────────────────────────────┘└┘└┘
doc     └─┘                 └────┘                                   
txt     └─┘                 └────┘                                   
par     └─┘                 └────┘                                   
pid                                                                
st     └────────────────────────────────────────────────────────────────
953  
src  
typ  
doc  
txt  
par  
pid  
st   
954  lemma mem_of_is_glb_of_is_closed {a : α} {s : set α} (ha : is_glb s a) (hs : s.nonempty) (sc : is_closed s) : a ∈ s :=
id                                                └─┘         └────┘          └───────┘        └───────┘       
src                                                └─┘          └────┘             └───────┘        └───────┘        
typ                                               └─┘         └────┘          └───────┘        └───────┘       
doc                                                             └────┘             └───────┘        └───────┘
955  by rw ←closure_eq_of_is_closed sc; exact mem_closure_of_is_glb ha hs
id          └─────────────────────┘ └┘        └───────────────────┘ └┘ └┘
src     └──┘└─────────────────────┘    └────┘└───────────────────┘    
typ     └──┘└─────────────────────┘└┘  └────┘└───────────────────┘└┘└┘
doc     └──┘                           └────┘                         
txt     └──┘                           └────┘                         
par     └──┘                           └────┘                         
pid       └┘                                                         
st     └──────────────────────────────────────────────────────────────────
956  
src  
typ  
doc  
txt  
par  
pid  
st   
957  /-- A compact set is bounded below -/
958  lemma bdd_below_of_compact {α : Type u} [topological_space α] [linear_order α]
id                                            └───────────────┘    └──────────┘ 
src                                           └───────────────┘     └──────────┘
typ                                           └───────────────┘    └──────────┘ 
doc                                           └───────────────┘
959    [order_closed_topology α] [nonempty α] {s : set α} (hs : compact s) : bdd_below s :=
id      └───────────────────┘    └──────┘        └─┘         └─────┘     └───────┘ 
src     └───────────────────┘     └──────┘         └─┘          └─────┘      └───────┘
typ     └───────────────────┘    └──────┘        └─┘         └─────┘     └───────┘ 
doc     └───────────────────┘                                   └─────┘      └───────┘
960  begin
st   └─────
961    by_contra H,
src    └─────────┘
typ    └─────────┘
doc    └─────────┘
txt    └─────────┘
par    └─────────┘
pid             └┘
st   ────────────┘└─
962    letI := classical.DLO α,
id             └───────────┘ 
src    └──────┘└───────────┘
typ    └──────┘└───────────┘
doc    └──────┘             
txt    └──────┘             
par    └──────┘             
pid        └─┘             
st   ────────────────────────┘└─
963    rcases hs.elim_finite_subcover_image (λ x (_ : x ∈ s), @is_open_Ioi _ _ _ _ x) _
id            └───────────────────────────┘                  └─────────┘
src    └─────┘└───────────────────────────┘  └──────┘  └─┘ └─────────┘└───────┘ └───
typ    └─────┘└───────────────────────────┘  └──────┘ └─┘ └─────────┘└───────┘ └───
doc    └─────┘                               └──────┘   └─┘            └───────┘ └───
txt    └─────┘                               └──────┘   └─┘            └───────┘ └───
par    └─────┘                               └──────┘   └─┘            └───────┘ └───
pid                                         └──────┘   └─┘            └───────┘ └───
st   ───────────────────────────────────────────────────────────────────────────────────
964      with ⟨t, st, ft, ht⟩,
src  ───────────────────────┘
typ  ───────────────────────┘
doc  ───────────────────────┘
txt  ───────────────────────┘
par  ───────────────────────┘
pid  ───────────────────────┘
st   ───────────────────────┘└─
965    { refine H ((bdd_below_finite ft).imp $ λ C hC y hy, _),
id                 └──────────────┘ └┘
src      └─────┘   └──────────────┘  └────┘  └────────────┘
typ      └─────┘  └──────────────┘└┘└────┘  └────────────┘
doc      └─────┘   └──────────────┘  └────┘  └────────────┘
txt      └─────┘                     └────┘  └────────────┘
par      └─────┘                     └────┘  └────────────┘
pid                                 └────┘  └────────────┘
st   ───┘└───────────────────────────────────────────────────┘└─
966      rcases mem_bUnion_iff.1 (ht hy) with ⟨x, hx, xy⟩,
id              └────────────┘    └┘ └┘
src      └─────┘└────────────┘└─┘     └────────────────┘
typ      └─────┘└────────────┘└─┘ └┘└┘└────────────────┘
doc      └─────┘              └─┘     └────────────────┘
txt      └─────┘              └─┘     └────────────────┘
par      └─────┘              └─┘     └────────────────┘
pid                          └─┘     └────────────────┘
st   ───────────────────────────────────────────────────┘└─
967      exact le_trans (hC hx) (le_of_lt xy) },
id             └──────┘  └┘ └┘   └──────┘ └┘
src      └────┘└──────┘     └┘ └──────┘  └┘
typ      └────┘└──────┘ └┘└┘└┘ └──────┘└┘└┘
doc      └────┘             └┘           └┘
txt      └────┘             └┘           └┘
par      └────┘             └┘           └┘
pid                        └┘           
st   ────────────────────────────────────────┘└┘
968    { refine λ x hx, mem_bUnion_iff.2 (not_imp_comm.1 _ H),
id                      └────────────┘    └──────────┘     
src      └─────┘ └─────┘└────────────┘└─┘ └──────────┘└───┘ 
typ      └─────┘ └─────┘└────────────┘└─┘ └──────────┘└───┘
doc      └─────┘ └─────┘              └─┘             └───┘ 
txt      └─────┘ └─────┘              └─┘             └───┘ 
par      └─────┘ └─────┘              └─┘             └───┘ 
pid             └─────┘              └─┘             └───┘ 
st   ───────────────────────────────────────────────────────┘└─
969      exact λ h, ⟨x, λ y hy, le_of_not_lt (h.imp $ λ ys, ⟨_, hy, ys⟩)⟩ }
id                             └──────────┘   └──┘
src      └────┘ └──┘  └┘ └─────┘└──────────┘  └──┘  └───┘ └─┘  └┘  └──┘
typ      └────┘ └──┘ └┘ └─────┘└──────────┘  └──┘  └───┘ └─┘  └┘  └──┘
doc      └────┘ └──┘  └┘ └─────┘                    └───┘ └─┘  └┘  └──┘
txt      └────┘ └──┘  └┘ └─────┘                    └───┘ └─┘  └┘  └──┘
par      └────┘ └──┘  └┘ └─────┘                    └───┘ └─┘  └┘  └──┘
pid            └──┘  └┘ └─────┘                    └───┘ └─┘  └┘  └─┘
st   ────────────────────────────────────────────────────────────────────┘└─
970  end
st   ──┘
971  
972  /-- A compact set is bounded above -/
973  lemma bdd_above_of_compact {α : Type u} [topological_space α] [linear_order α]
id                                            └───────────────┘    └──────────┘ 
src                                           └───────────────┘     └──────────┘
typ                                           └───────────────┘    └──────────┘ 
doc                                           └───────────────┘
974    [order_topology α] : Π [nonempty α] {s : set α}, compact s → bdd_above s :=
id      └────────────┘        └──────┘        └─┘    └─────┘    └───────┘ 
src     └────────────┘         └──────┘         └─┘     └─────┘     └───────┘
typ     └────────────┘        └──────┘        └─┘    └─────┘    └───────┘ 
doc     └────────────┘                                  └─────┘     └───────┘
975  @bdd_below_of_compact (order_dual α) _ _ _
id    └──────────────────┘  └────────┘ 
src   └──────────────────┘  └────────┘
typ   └──────────────────┘  └────────┘ 
doc   └──────────────────┘  └────────┘
976  
977  end order_topology
978  
979  section linear_order
980  
981  variables [topological_space α] [linear_order α] [order_topology α] [densely_ordered α]
id              └───────────────┘     └──────────┘     └────────────┘     └─────────────┘
src             └───────────────┘     └──────────┘     └────────────┘     └─────────────┘
typ             └───────────────┘     └──────────┘     └────────────┘     └─────────────┘
doc             └───────────────┘                      └────────────┘     └─────────────┘
982  
983  /-- The closure of the interval `(a, +∞)` is the closed interval `[a, +∞)`, unless `a` is a top
984  element. -/
985  lemma closure_Ioi' {a b : α} (hab : a < b) :
id                                        
src                                        
typ                                       
986    closure (Ioi a) = Ici a :=
id     └─────┘  └─┘    └─┘ 
src    └─────┘  └─┘     └─┘
typ    └─────┘  └─┘    └─┘ 
doc    └─────┘  └─┘      └─┘
987  begin
st   └─────
988    apply subset.antisymm,
id           └─────────────┘
src    └────┘└─────────────┘
typ    └────┘└─────────────┘
doc    └────┘
txt    └────┘
par    └────┘
pid         
st   ──────────────────────┘└─
989    { exact closure_minimal Ioi_subset_Ici_self is_closed_Ici },
id             └─────────────┘ └─────────────────┘ └───────────┘
src      └────┘└─────────────┘└─────────────────┘└───────────┘
typ      └────┘└─────────────┘└─────────────────┘└───────────┘
doc      └────┘                                               
txt      └────┘                                               
par      └────┘                                               
pid                                                          
st   ───┘└──────────────────────────────────────────────────────┘└┘
990    { assume x hx,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ──────────────┘└─
991      by_cases h : x = a,
id                      
src      └───────┘ └─┘ 
typ      └───────┘ └─┘
doc      └───────┘ └─┘  
txt      └───────┘ └─┘  
par      └───────┘ └─┘  
pid               └─┘  
st   ─────────────────────┘└─
992      { rw h, exact mem_closure_of_is_glb is_glb_Ioi ⟨_, hab⟩ },
id                    └───────────────────┘ └────────┘     └─┘
src        └─┘   └────┘└───────────────────┘└────────┘ └─┘   └┘
typ        └─┘  └────┘└───────────────────┘└────────┘ └─┘└─┘└┘
doc        └─┘   └────┘                                └─┘   └┘
txt        └─┘   └────┘                                └─┘   └┘
par        └─┘   └────┘                                └─┘   └┘
pid                                                  └─┘   
st   ─────┘└──┘└────────────────────────────────────────────────┘└┘
993      { exact subset_closure (lt_of_le_of_ne hx (ne.symm h)) } }
id               └────────────┘  └────────────┘ └┘  └─────┘ 
src        └────┘└────────────┘ └────────────┘   └─────┘ └─┘
typ        └────┘└────────────┘ └────────────┘└┘ └─────┘└─┘
doc        └────┘                                        └─┘
txt        └────┘                                        └─┘
par        └────┘                                        └─┘
pid                                                     └┘
st   ──────────────────────────────────────────────────────────┘└───
994  end
st   ──┘
995  
996  /-- The closure of the interval `(a, +∞)` is the closed interval `[a, +∞)`. -/
997  lemma closure_Ioi (a : α) [no_top_order α] :
id                             └──────────┘ 
src                             └──────────┘
typ                            └──────────┘ 
doc                             └──────────┘
998    closure (Ioi a) = Ici a :=
id     └─────┘  └─┘    └─┘ 
src    └─────┘  └─┘     └─┘
typ    └─────┘  └─┘    └─┘ 
doc    └─────┘  └─┘      └─┘
999  let ⟨b, hb⟩ := no_top a in closure_Ioi' hb
id   └─┘     └┘     └────┘     └──────────┘
src                 └────┘      └──────────┘
typ  └─┘     └┘     └────┘     └──────────┘
doc                             └──────────┘
1000  
1001  /-- The closure of the interval `(-∞, a)` is the closed interval `(-∞, a]`, unless `a` is a bottom
1002  element. -/
1003  lemma closure_Iio' {a b : α} (hab : b < a) :
id                                        
src                                        
typ                                       
1004    closure (Iio a) = Iic a :=
id     └─────┘  └─┘    └─┘ 
src    └─────┘  └─┘     └─┘
typ    └─────┘  └─┘    └─┘ 
doc    └─────┘  └─┘      └─┘
1005  begin
st   └─────
1006    apply subset.antisymm,
id           └─────────────┘
src    └────┘└─────────────┘
typ    └────┘└─────────────┘
doc    └────┘
txt    └────┘
par    └────┘
pid         
st   ──────────────────────┘└─
1007    { exact closure_minimal Iio_subset_Iic_self is_closed_Iic },
id             └─────────────┘ └─────────────────┘ └───────────┘
src      └────┘└─────────────┘└─────────────────┘└───────────┘
typ      └────┘└─────────────┘└─────────────────┘└───────────┘
doc      └────┘                                               
txt      └────┘                                               
par      └────┘                                               
pid                                                          
st   ───┘└──────────────────────────────────────────────────────┘└┘
1008    { assume x hx,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ──────────────┘└─
1009      by_cases h : x = a,
id                      
src      └───────┘ └─┘ 
typ      └───────┘ └─┘
doc      └───────┘ └─┘  
txt      └───────┘ └─┘  
par      └───────┘ └─┘  
pid               └─┘  
st   ─────────────────────┘└─
1010      { rw h, exact mem_closure_of_is_lub is_lub_Iio ⟨_, hab⟩ },
id                    └───────────────────┘ └────────┘     └─┘
src        └─┘   └────┘└───────────────────┘└────────┘ └─┘   └┘
typ        └─┘  └────┘└───────────────────┘└────────┘ └─┘└─┘└┘
doc        └─┘   └────┘                                └─┘   └┘
txt        └─┘   └────┘                                └─┘   └┘
par        └─┘   └────┘                                └─┘   └┘
pid                                                  └─┘   
st   ─────┘└──┘└────────────────────────────────────────────────┘└┘
1011      { apply subset_closure, by simpa [h] using lt_or_eq_of_le hx } }
id               └────────────┘                    └────────────┘ └┘
src        └────┘└────────────┘     └─────┘ └──────┘└────────────┘  
typ        └────┘└────────────┘     └─────┘└──────┘└────────────┘└┘
doc        └────┘                   └─────┘ └──────┘                
txt        └────┘                   └─────┘ └──────┘                
par        └────┘                   └─────┘ └──────┘                
pid                                      └────┘                
st   ─────────────────────────┘                                       └───
1012  end
st   ──┘
1013  
1014  /-- The closure of the interval `(-∞, a)` is the interval `(-∞, a]`. -/
1015  lemma closure_Iio (a : α) [no_bot_order α] :
id                             └──────────┘ 
src                             └──────────┘
typ                            └──────────┘ 
doc                             └──────────┘
1016    closure (Iio a) = Iic a :=
id     └─────┘  └─┘    └─┘ 
src    └─────┘  └─┘     └─┘
typ    └─────┘  └─┘    └─┘ 
doc    └─────┘  └─┘      └─┘
1017  let ⟨b, hb⟩ := no_bot a in closure_Iio' hb
id   └─┘     └┘     └────┘     └──────────┘
src                 └────┘      └──────────┘
typ  └─┘     └┘     └────┘     └──────────┘
doc                             └──────────┘
1018  
1019  /-- The closure of the open interval `(a, b)` is the closed interval `[a, b]`. -/
1020  lemma closure_Ioo {a b : α} (hab : a < b) :
id                                       
src                                       
typ                                      
1021    closure (Ioo a b) = Icc a b :=
id     └─────┘  └─┘     └─┘  
src    └─────┘  └─┘       └─┘
typ    └─────┘  └─┘     └─┘  
doc    └─────┘  └─┘        └─┘
1022  begin
st   └─────
1023    apply subset.antisymm,
id           └─────────────┘
src    └────┘└─────────────┘
typ    └────┘└─────────────┘
doc    └────┘
txt    └────┘
par    └────┘
pid         
st   ──────────────────────┘└─
1024    { exact closure_minimal Ioo_subset_Icc_self is_closed_Icc },
id             └─────────────┘ └─────────────────┘ └───────────┘
src      └────┘└─────────────┘└─────────────────┘└───────────┘
typ      └────┘└─────────────┘└─────────────────┘└───────────┘
doc      └────┘                                               
txt      └────┘                                               
par      └────┘                                               
pid                                                          
st   ───┘└──────────────────────────────────────────────────────┘└┘
1025    { have hab' : (Ioo a b).nonempty, from nonempty_Ioo.2 hab,
id                    └─┘                   └──────────┘   └─┘
src      └──────────┘ └─┘  └────────┘  └───┘└──────────┘└─┘
typ      └──────────┘ └─┘└────────┘  └───┘└──────────┘└─┘└─┘
doc      └──────────┘ └─┘  └────────┘  └───┘            └─┘
txt      └──────────┘      └────────┘  └───┘            └─┘
par      └──────────┘      └────────┘  └───┘            └─┘
pid      └───────┘└─┘      └───────┘  └───┘            └─┘
st   ─────────────────────────────────┘└───────────────────────┘└─
1026      assume x hx,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ──────────────┘└─
1027      by_cases h : x = a,
id                      
src      └───────┘ └─┘ 
typ      └───────┘ └─┘
doc      └───────┘ └─┘  
txt      └───────┘ └─┘  
par      └───────┘ └─┘  
pid               └─┘  
st   ─────────────────────┘└─
1028      { rw h, exact mem_closure_of_is_glb (is_glb_Ioo hab) hab' },
id                    └───────────────────┘  └────────┘ └─┘  └──┘
src        └─┘   └────┘└───────────────────┘ └────────┘   └┘    
typ        └─┘  └────┘└───────────────────┘ └────────┘└─┘└┘└──┘
doc        └─┘   └────┘                                   └┘    
txt        └─┘   └────┘                                   └┘    
par        └─┘   └────┘                                   └┘    
pid                                                     └┘    
st   ─────┘└──┘└──────────────────────────────────────────────────┘└┘
1029      by_cases h' : x = b,
id                        
src      └───────┘  └─┘  
typ      └───────┘  └─┘ 
doc      └───────┘  └─┘  
txt      └───────┘  └─┘  
par      └───────┘  └─┘  
pid                └─┘  
st   ──────────────────────┘└─
1030      { rw h', refine mem_closure_of_is_lub (is_lub_Ioo hab) hab' },
id            └┘         └───────────────────┘  └────────┘ └─┘  └──┘
src        └─┘    └─────┘└───────────────────┘ └────────┘   └┘    
typ        └─┘└┘  └─────┘└───────────────────┘ └────────┘└─┘└┘└──┘
doc        └─┘    └─────┘                                   └┘    
txt        └─┘    └─────┘                                   └┘    
par        └─┘    └─────┘                                   └┘    
pid                                                       └┘    
st   ─────┘└───┘└───────────────────────────────────────────────────┘└┘
1031      exact subset_closure ⟨lt_of_le_of_ne hx.1 (ne.symm h), by simpa [h'] using lt_or_eq_of_le hx.2⟩ }
id             └────────────┘  └────────────┘ └┘    └─────┘              └┘        └────────────┘ └┘
src      └────┘└────────────┘ └────────────┘  └─┘ └─────┘ └─┘  └─────┘  └──────┘└────────────┘  └┘└┘
typ      └────┘└────────────┘ └────────────┘└┘└─┘ └─────┘└─┘  └─────┘└┘└──────┘└────────────┘└┘└┘└┘
doc      └────┘                               └─┘         └─┘  └─────┘  └──────┘                └┘└┘
txt      └────┘                               └─┘         └─┘  └─────┘  └──────┘                └┘└┘
par      └────┘                               └─┘         └─┘  └─────┘  └──────┘                └┘└┘
pid                                          └─┘         └─┘  └──────┘  └──────┘                └─┘
st   ────────────────────────────────────────────────────────────┘└───────────────────────────────────┘└┘└─
1032  end
st   ──┘
1033  
1034  /-- The closure of the interval `(a, b]` is the closed interval `[a, b]`. -/
1035  lemma closure_Ioc {a b : α} (hab : a < b) :
id                                       
src                                       
typ                                      
1036    closure (Ioc a b) = Icc a b :=
id     └─────┘  └─┘     └─┘  
src    └─────┘  └─┘       └─┘
typ    └─────┘  └─┘     └─┘  
doc    └─────┘  └─┘        └─┘
1037  begin
st   └─────
1038    apply subset.antisymm,
id           └─────────────┘
src    └────┘└─────────────┘
typ    └────┘└─────────────┘
doc    └────┘
txt    └────┘
par    └────┘
pid         
st   ──────────────────────┘└─
1039    { exact closure_minimal Ioc_subset_Icc_self is_closed_Icc },
id             └─────────────┘ └─────────────────┘ └───────────┘
src      └────┘└─────────────┘└─────────────────┘└───────────┘
typ      └────┘└─────────────┘└─────────────────┘└───────────┘
doc      └────┘                                               
txt      └────┘                                               
par      └────┘                                               
pid                                                          
st   ───┘└──────────────────────────────────────────────────────┘└┘
1040    { apply subset.trans _ (closure_mono Ioo_subset_Ioc_self),
id             └──────────┘    └──────────┘ └─────────────────┘
src      └────┘└──────────┘└─┘ └──────────┘└─────────────────┘
typ      └────┘└──────────┘└─┘ └──────────┘└─────────────────┘
doc      └────┘            └─┘                                
txt      └────┘            └─┘                                
par      └────┘            └─┘                                
pid                       └─┘                                
st   ──────────────────────────────────────────────────────────┘└─
1041      rw closure_Ioo hab }
id          └─────────┘ └─┘
src      └─┘└─────────┘   
typ      └─┘└─────────┘└─┘
doc      └─┘└─────────┘   
txt      └─┘              
par      └─┘              
pid                      
st   ──────────────────────┘└─
1042  end
st   ──┘
1043  
1044  /-- The closure of the interval `[a, b)` is the closed interval `[a, b]`. -/
1045  lemma closure_Ico {a b : α} (hab : a < b) :
id                                       
src                                       
typ                                      
1046    closure (Ico a b) = Icc a b :=
id     └─────┘  └─┘     └─┘  
src    └─────┘  └─┘       └─┘
typ    └─────┘  └─┘     └─┘  
doc    └─────┘  └─┘        └─┘
1047  begin
st   └─────
1048    apply subset.antisymm,
id           └─────────────┘
src    └────┘└─────────────┘
typ    └────┘└─────────────┘
doc    └────┘
txt    └────┘
par    └────┘
pid         
st   ──────────────────────┘└─
1049    { exact closure_minimal Ico_subset_Icc_self is_closed_Icc },
id             └─────────────┘ └─────────────────┘ └───────────┘
src      └────┘└─────────────┘└─────────────────┘└───────────┘
typ      └────┘└─────────────┘└─────────────────┘└───────────┘
doc      └────┘                                               
txt      └────┘                                               
par      └────┘                                               
pid                                                          
st   ───┘└──────────────────────────────────────────────────────┘└┘
1050    { apply subset.trans _ (closure_mono Ioo_subset_Ico_self),
id             └──────────┘    └──────────┘ └─────────────────┘
src      └────┘└──────────┘└─┘ └──────────┘└─────────────────┘
typ      └────┘└──────────┘└─┘ └──────────┘└─────────────────┘
doc      └────┘            └─┘                                
txt      └────┘            └─┘                                
par      └────┘            └─┘                                
pid                       └─┘                                
st   ──────────────────────────────────────────────────────────┘└─
1051      rw closure_Ioo hab }
id          └─────────┘ └─┘
src      └─┘└─────────┘   
typ      └─┘└─────────┘└─┘
doc      └─┘└─────────┘   
txt      └─┘              
par      └─┘              
pid                      
st   ──────────────────────┘└─
1052  end
st   ──┘
1053  
1054  lemma nhds_within_Ioi_ne_bot' {a b c : α} (H₁ : a < c) (H₂ : a ≤ b) :
id                                                              
src                                                                
typ                                                             
1055    nhds_within b (Ioi a) ≠ ⊥ :=
id     └─────────┘   └─┘    
src    └─────────┘    └─┘     
typ    └─────────┘   └─┘    
doc    └─────────┘    └─┘
1056  mem_closure_iff_nhds_within_ne_bot.1 $ by { rw [closure_Ioi' H₁], exact H₂ }
id   └────────────────────────────────┘             └──────────┘ └┘         └┘
src  └────────────────────────────────┘         └──┘└──────────┘    └────┘  
typ  └────────────────────────────────┘         └──┘└──────────┘└┘  └────┘└┘
doc                                              └──┘└──────────┘    └────┘  
txt                                              └──┘                └────┘  
par                                              └──┘                └────┘  
pid                                                └┘                       
st                                            └────────────────────┘└──────────┘└┘
1057  
1058  lemma nhds_within_Ioi_ne_bot [no_top_order α] {a b : α} (H : a ≤ b) :
id                                 └──────────┘                   
src                                └──────────┘                     
typ                                └──────────┘                   
doc                                └──────────┘
1059    nhds_within b (Ioi a) ≠ ⊥ :=
id     └─────────┘   └─┘    
src    └─────────┘    └─┘     
typ    └─────────┘   └─┘    
doc    └─────────┘    └─┘
1060  let ⟨c, hc⟩ := no_top a in nhds_within_Ioi_ne_bot' hc H
id   └─┘     └┘     └────┘     └─────────────────────┘    
src                 └────┘      └─────────────────────┘
typ  └─┘     └┘     └────┘     └─────────────────────┘    
1061  
1062  lemma nhds_within_Ioi_self_ne_bot' {a b : α} (H : a < b) :
id                                                      
src                                                      
typ                                                     
1063    nhds_within a (Ioi a) ≠ ⊥ :=
id     └─────────┘   └─┘    
src    └─────────┘    └─┘     
typ    └─────────┘   └─┘    
doc    └─────────┘    └─┘
1064  nhds_within_Ioi_ne_bot' H (le_refl a)
id   └─────────────────────┘   └─────┘ 
src  └─────────────────────┘    └─────┘
typ  └─────────────────────┘   └─────┘ 
1065  
1066  lemma nhds_within_Ioi_self_ne_bot [no_top_order α] (a : α) :
id                                      └──────────┘        
src                                     └──────────┘
typ                                     └──────────┘        
doc                                     └──────────┘
1067    nhds_within a (Ioi a) ≠ ⊥ :=
id     └─────────┘   └─┘    
src    └─────────┘    └─┘     
typ    └─────────┘   └─┘    
doc    └─────────┘    └─┘
1068  nhds_within_Ioi_ne_bot (le_refl a)
id   └────────────────────┘  └─────┘ 
src  └────────────────────┘  └─────┘
typ  └────────────────────┘  └─────┘ 
1069  
1070  lemma nhds_within_Iio_ne_bot' {a b c : α} (H₁ : a < c) (H₂ : b ≤ c) :
id                                                              
src                                                                
typ                                                             
1071    nhds_within b (Iio c) ≠ ⊥ :=
id     └─────────┘   └─┘    
src    └─────────┘    └─┘     
typ    └─────────┘   └─┘    
doc    └─────────┘    └─┘
1072  mem_closure_iff_nhds_within_ne_bot.1 $ by { rw [closure_Iio' H₁], exact H₂ }
id   └────────────────────────────────┘             └──────────┘ └┘         └┘
src  └────────────────────────────────┘         └──┘└──────────┘    └────┘  
typ  └────────────────────────────────┘         └──┘└──────────┘└┘  └────┘└┘
doc                                              └──┘└──────────┘    └────┘  
txt                                              └──┘                └────┘  
par                                              └──┘                └────┘  
pid                                                └┘                       
st                                            └────────────────────┘└──────────┘└┘
1073  
1074  lemma nhds_within_Iio_ne_bot [no_bot_order α] {a b : α} (H : a ≤ b) :
id                                 └──────────┘                   
src                                └──────────┘                     
typ                                └──────────┘                   
doc                                └──────────┘
1075    nhds_within a (Iio b) ≠ ⊥ :=
id     └─────────┘   └─┘    
src    └─────────┘    └─┘     
typ    └─────────┘   └─┘    
doc    └─────────┘    └─┘
1076  let ⟨c, hc⟩ := no_bot b in nhds_within_Iio_ne_bot' hc H
id   └─┘     └┘     └────┘     └─────────────────────┘    
src                 └────┘      └─────────────────────┘
typ  └─┘     └┘     └────┘     └─────────────────────┘    
1077  
1078  lemma nhds_within_Iio_self_ne_bot' {a b : α} (H : a < b) :
id                                                      
src                                                      
typ                                                     
1079    nhds_within b (Iio b) ≠ ⊥ :=
id     └─────────┘   └─┘    
src    └─────────┘    └─┘     
typ    └─────────┘   └─┘    
doc    └─────────┘    └─┘
1080  nhds_within_Iio_ne_bot' H (le_refl b)
id   └─────────────────────┘   └─────┘ 
src  └─────────────────────┘    └─────┘
typ  └─────────────────────┘   └─────┘ 
1081  
1082  lemma nhds_within_Iio_self_ne_bot [no_bot_order α] (a : α) :
id                                      └──────────┘        
src                                     └──────────┘
typ                                     └──────────┘        
doc                                     └──────────┘
1083    nhds_within a (Iio a) ≠ ⊥ :=
id     └─────────┘   └─┘    
src    └─────────┘    └─┘     
typ    └─────────┘   └─┘    
doc    └─────────┘    └─┘
1084  nhds_within_Iio_ne_bot (le_refl a)
id   └────────────────────┘  └─────┘ 
src  └────────────────────┘  └─────┘
typ  └────────────────────┘  └─────┘ 
1085  
1086  end linear_order
1087  
1088  section complete_linear_order
1089  
1090  variables [complete_linear_order α] [topological_space α] [order_topology α]
id              └───────────────────┘     └───────────────┘     └────────────┘
src             └───────────────────┘     └───────────────┘     └────────────┘
typ             └───────────────────┘     └───────────────┘     └────────────┘
doc             └───────────────────┘     └───────────────┘     └────────────┘
1091    [complete_linear_order β] [topological_space β] [order_topology β] [nonempty γ]
id      └───────────────────┘     └───────────────┘     └────────────┘     └──────┘
src     └───────────────────┘     └───────────────┘     └────────────┘     └──────┘
typ     └───────────────────┘     └───────────────┘     └────────────┘     └──────┘
doc     └───────────────────┘     └───────────────┘     └────────────┘
1092  
1093  lemma Sup_mem_closure {α : Type u} [topological_space α] [complete_linear_order α] [order_topology α]
id                                       └───────────────┘    └───────────────────┘    └────────────┘ 
src                                      └───────────────┘     └───────────────────┘     └────────────┘
typ                                      └───────────────┘    └───────────────────┘    └────────────┘ 
doc                                      └───────────────┘     └───────────────────┘     └────────────┘
1094    {s : set α} (hs : s.nonempty) : Sup s ∈ closure s :=
id          └─┘         └───────┘    └─┘   └─────┘ 
src         └─┘           └───────┘    └─┘    └─────┘
typ         └─┘         └───────┘    └─┘   └─────┘ 
doc                       └───────┘    └─┘     └─────┘
1095  mem_closure_of_is_lub is_lub_Sup hs
id   └───────────────────┘ └────────┘ └┘
src  └───────────────────┘ └────────┘
typ  └───────────────────┘ └────────┘ └┘
1096  
1097  lemma Inf_mem_closure {α : Type u} [topological_space α] [complete_linear_order α] [order_topology α]
id                                       └───────────────┘    └───────────────────┘    └────────────┘ 
src                                      └───────────────┘     └───────────────────┘     └────────────┘
typ                                      └───────────────┘    └───────────────────┘    └────────────┘ 
doc                                      └───────────────┘     └───────────────────┘     └────────────┘
1098    {s : set α} (hs : s.nonempty) : Inf s ∈ closure s :=
id          └─┘         └───────┘    └─┘   └─────┘ 
src         └─┘           └───────┘    └─┘    └─────┘
typ         └─┘         └───────┘    └─┘   └─────┘ 
doc                       └───────┘    └─┘     └─────┘
1099  mem_closure_of_is_glb is_glb_Inf hs
id   └───────────────────┘ └────────┘ └┘
src  └───────────────────┘ └────────┘
typ  └───────────────────┘ └────────┘ └┘
1100  
1101  lemma Sup_mem_of_is_closed {α : Type u} [topological_space α] [complete_linear_order α] [order_topology α]
id                                            └───────────────┘    └───────────────────┘    └────────────┘ 
src                                           └───────────────┘     └───────────────────┘     └────────────┘
typ                                           └───────────────┘    └───────────────────┘    └────────────┘ 
doc                                           └───────────────┘     └───────────────────┘     └────────────┘
1102    {s : set α} (hs : s.nonempty) (hc : is_closed s) : Sup s ∈ s :=
id          └─┘         └───────┘        └───────┘     └─┘   
src         └─┘           └───────┘        └───────┘      └─┘   
typ         └─┘         └───────┘        └───────┘     └─┘   
doc                       └───────┘        └───────┘      └─┘
1103  mem_of_is_lub_of_is_closed  is_lub_Sup hs hc
id   └────────────────────────┘  └────────┘ └┘ └┘
src  └────────────────────────┘  └────────┘
typ  └────────────────────────┘  └────────┘ └┘ └┘
1104  
1105  lemma Inf_mem_of_is_closed {α : Type u} [topological_space α] [complete_linear_order α] [order_topology α]
id                                            └───────────────┘    └───────────────────┘    └────────────┘ 
src                                           └───────────────┘     └───────────────────┘     └────────────┘
typ                                           └───────────────┘    └───────────────────┘    └────────────┘ 
doc                                           └───────────────┘     └───────────────────┘     └────────────┘
1106    {s : set α} (hs : s.nonempty) (hc : is_closed s) : Inf s ∈ s :=
id          └─┘         └───────┘        └───────┘     └─┘   
src         └─┘           └───────┘        └───────┘      └─┘   
typ         └─┘         └───────┘        └───────┘     └─┘   
doc                       └───────┘        └───────┘      └─┘
1107  mem_of_is_glb_of_is_closed  is_glb_Inf hs hc
id   └────────────────────────┘  └────────┘ └┘ └┘
src  └────────────────────────┘  └────────┘
typ  └────────────────────────┘  └────────┘ └┘ └┘
1108  
1109  /-- A continuous monotone function sends supremum to supremum for nonempty sets. -/
1110  lemma Sup_of_continuous' {f : α → β} (Mf : continuous f) (Cf : monotone f)
id                                            └────────┘         └──────┘ 
src                                             └────────┘          └──────┘
typ                                           └────────┘         └──────┘ 
doc                                             └────────┘          └──────┘
1111    {s : set α} (hs : s.nonempty) : f (Sup s) = Sup (f '' s) :=
id          └─┘         └───────┘      └─┘    └─┘   └┘ 
src         └─┘           └───────┘       └─┘     └─┘    └┘
typ         └─┘         └───────┘      └─┘    └─┘   └┘ 
doc                       └───────┘       └─┘      └─┘
1112  --This is a particular case of the more general is_lub_of_is_lub_of_tendsto
1113  (is_lub_iff_Sup_eq.1
id    └───────────────┘
src   └───────────────┘
typ   └───────────────┘
1114    (is_lub_of_is_lub_of_tendsto (λ x hx y hy xy, Cf xy) is_lub_Sup hs $
id      └─────────────────────────┘     └┘  └┘ └┘  └┘ └┘  └────────┘ └┘
src     └─────────────────────────┘                         └────────┘
typ     └─────────────────────────┘     └┘  └┘ └┘  └┘ └┘  └────────┘ └┘
1115      tendsto_le_left inf_le_left (Mf.tendsto _))).symm
id       └─────────────┘ └─────────┘  └┘└──────┘     └──┘
src      └─────────────┘ └─────────┘    └──────┘     └──┘
typ      └─────────────┘ └─────────┘  └┘└──────┘     └──┘
1116  
1117  /-- A continuous monotone function sending bot to bot sends supremum to supremum. -/
1118  lemma Sup_of_continuous {f : α → β} (Mf : continuous f) (Cf : monotone f)
id                                           └────────┘         └──────┘ 
src                                            └────────┘          └──────┘
typ                                          └────────┘         └──────┘ 
doc                                            └────────┘          └──────┘
1119    (fbot : f ⊥ = ⊥) {s : set α} : f (Sup s) = Sup (f '' s) :=
id                       └─┘       └─┘    └─┘   └┘ 
src                       └─┘         └─┘     └─┘    └┘
typ                      └─┘       └─┘    └─┘   └┘ 
doc                                      └─┘      └─┘
1120  begin
st   └─────
1121    cases s.eq_empty_or_nonempty with h h,
id           └────────────────────┘
src    └────┘└────────────────────┘└───────┘
typ    └────┘└────────────────────┘└───────┘
doc    └────┘                      └───────┘
txt    └────┘                      └───────┘
par    └────┘                      └───────┘
pid                               └───────┘
st   ──────────────────────────────────────┘└─
1122    { simp [h, fbot] },
id               └──┘
src      └────┘ └┘    └┘
typ      └────┘└┘└──┘└┘
doc      └────┘ └┘    └┘
txt      └────┘ └┘    └┘
par      └────┘ └┘    └┘
pid           └┘    
st   ───┘└─────────────┘└┘
1123    { exact Sup_of_continuous' Mf Cf h }
id             └────────────────┘ └┘ └┘ 
src      └────┘└────────────────┘     
typ      └────┘└────────────────┘└┘└┘
doc      └────┘└────────────────┘     
txt      └────┘                       
par      └────┘                       
pid                                  
st   ────────────────────────────────────┘└─
1124  end
st   ──┘
1125  
1126  /-- A continuous monotone function sends indexed supremum to indexed supremum. -/
1127  lemma supr_of_continuous {f : α → β} {g : γ → α}
id                                              
typ                                             
1128    (Mf : continuous f) (Cf : monotone f) : f (supr g) = supr (f ∘ g) :=
id           └────────┘         └──────┘       └──┘    └──┘    
src          └────────┘          └──────┘         └──┘     └──┘    
typ          └────────┘         └──────┘       └──┘    └──┘    
doc          └────────┘          └──────┘         └──┘      └──┘
1129  by { rw [supr, Sup_of_continuous' Mf Cf (range_nonempty g), ← range_comp, supr] }
id            └──┘  └────────────────┘ └┘ └┘  └────────────┘      └────────┘  └──┘
src       └──┘└──┘└┘└────────────────┘     └────────────┘ └───┘└────────┘└┘└──┘└┘
typ       └──┘└──┘└┘└────────────────┘└┘└┘ └────────────┘└───┘└────────┘└┘└──┘└┘
doc       └──┘└──┘└┘└────────────────┘                    └───┘          └┘└──┘└┘
txt       └──┘    └┘                                      └───┘          └┘    └┘
par       └──┘    └┘                                      └───┘          └┘    └┘
pid         └┘    └┘                                      └───┘          └┘    
st     └─────────┘└───────────────────────────────────────────┘└────────────┘└────┘└┘
1130  
1131  /-- A continuous monotone function sends infimum to infimum for nonempty sets. -/
1132  lemma Inf_of_continuous' {f : α → β} (Mf : continuous f) (Cf : monotone f)
id                                            └────────┘         └──────┘ 
src                                             └────────┘          └──────┘
typ                                           └────────┘         └──────┘ 
doc                                             └────────┘          └──────┘
1133    {s : set α} (hs : s.nonempty) : f (Inf s) = Inf (f '' s) :=
id          └─┘         └───────┘      └─┘    └─┘   └┘ 
src         └─┘           └───────┘       └─┘     └─┘    └┘
typ         └─┘         └───────┘      └─┘    └─┘   └┘ 
doc                       └───────┘       └─┘      └─┘
1134  (is_glb_iff_Inf_eq.1
id    └───────────────┘
src   └───────────────┘
typ   └───────────────┘
1135    (is_glb_of_is_glb_of_tendsto (λ x hx y hy xy, Cf xy) is_glb_Inf hs $
id      └─────────────────────────┘     └┘  └┘ └┘  └┘ └┘  └────────┘ └┘
src     └─────────────────────────┘                         └────────┘
typ     └─────────────────────────┘     └┘  └┘ └┘  └┘ └┘  └────────┘ └┘
1136      tendsto_le_left inf_le_left (Mf.tendsto _))).symm
id       └─────────────┘ └─────────┘  └┘└──────┘     └──┘
src      └─────────────┘ └─────────┘    └──────┘     └──┘
typ      └─────────────┘ └─────────┘  └┘└──────┘     └──┘
1137  
1138  /-- A continuous monotone function sending top to top sends infimum to infimum. -/
1139  lemma Inf_of_continuous {f : α → β} (Mf : continuous f) (Cf : monotone f)
id                                           └────────┘         └──────┘ 
src                                            └────────┘          └──────┘
typ                                          └────────┘         └──────┘ 
doc                                            └────────┘          └──────┘
1140    (ftop : f ⊤ = ⊤) {s : set α} : f (Inf s) = Inf (f '' s) :=
id                       └─┘       └─┘    └─┘   └┘ 
src                       └─┘         └─┘     └─┘    └┘
typ                      └─┘       └─┘    └─┘   └┘ 
doc                                      └─┘      └─┘
1141  begin
st   └─────
1142    cases s.eq_empty_or_nonempty with h h,
id           └────────────────────┘
src    └────┘└────────────────────┘└───────┘
typ    └────┘└────────────────────┘└───────┘
doc    └────┘                      └───────┘
txt    └────┘                      └───────┘
par    └────┘                      └───────┘
pid                               └───────┘
st   ──────────────────────────────────────┘└─
1143    { simpa [h] },
id              
src      └─────┘ └┘
typ      └─────┘└┘
doc      └─────┘ └┘
txt      └─────┘ └┘
par      └─────┘ └┘
pid            
st   ───┘└────────┘└┘
1144    { exact Inf_of_continuous' Mf Cf h }
id             └────────────────┘ └┘ └┘ 
src      └────┘└────────────────┘     
typ      └────┘└────────────────┘└┘└┘
doc      └────┘└────────────────┘     
txt      └────┘                       
par      └────┘                       
pid                                  
st   ────────────────────────────────────┘└─
1145  end
st   ──┘
1146  
1147  /-- A continuous monotone function sends indexed infimum to indexed infimum. -/
1148  lemma infi_of_continuous {f : α → β} {g : γ → α}
id                                              
typ                                             
1149    (Mf : continuous f) (Cf : monotone f) : f (infi g) = infi (f ∘ g) :=
id           └────────┘         └──────┘       └──┘    └──┘    
src          └────────┘          └──────┘         └──┘     └──┘    
typ          └────────┘         └──────┘       └──┘    └──┘    
doc          └────────┘          └──────┘         └──┘      └──┘
1150  by rw [infi, Inf_of_continuous' Mf Cf (range_nonempty g), ← range_comp, infi]
id          └──┘  └────────────────┘ └┘ └┘  └────────────┘      └────────┘  └──┘
src     └──┘└──┘└┘└────────────────┘     └────────────┘ └───┘└────────┘└┘└──┘└─
typ     └──┘└──┘└┘└────────────────┘└┘└┘ └────────────┘└───┘└────────┘└┘└──┘└─
doc     └──┘└──┘└┘└────────────────┘                    └───┘          └┘└──┘└─
txt     └──┘    └┘                                      └───┘          └┘    └─
par     └──┘    └┘                                      └───┘          └┘    └─
pid       └┘    └┘                                      └───┘          └┘    
st     └───────┘└───────────────────────────────────────────┘└────────────┘└────┘
1151  
src  
typ  
doc  
txt  
par  
pid  
st   
1152  end complete_linear_order
1153  
1154  
1155  section conditionally_complete_linear_order
1156  
1157  variables [conditionally_complete_linear_order α] [topological_space α] [order_topology α]
id              └─────────────────────────────────┘    └───────────────┘     └────────────┘
src             └─────────────────────────────────┘     └───────────────┘     └────────────┘
typ             └─────────────────────────────────┘    └───────────────┘     └────────────┘
doc                                                     └───────────────┘     └────────────┘
1158    [conditionally_complete_linear_order β] [topological_space β] [order_topology β] [nonempty γ]
id      └─────────────────────────────────┘     └───────────────┘     └────────────┘     └──────┘
src     └─────────────────────────────────┘     └───────────────┘     └────────────┘     └──────┘
typ     └─────────────────────────────────┘     └───────────────┘     └────────────┘     └──────┘
doc                                             └───────────────┘     └────────────┘
1159  
1160  lemma cSup_mem_closure {α : Type u} [topological_space α] [conditionally_complete_linear_order α] [order_topology α]
id                                        └───────────────┘    └─────────────────────────────────┘    └────────────┘ 
src                                       └───────────────┘     └─────────────────────────────────┘     └────────────┘
typ                                       └───────────────┘    └─────────────────────────────────┘    └────────────┘ 
doc                                       └───────────────┘                                             └────────────┘
1161    {s : set α} (hs : s.nonempty) (B : bdd_above s) : Sup s ∈ closure s :=
id          └─┘         └───────┘       └───────┘     └─┘   └─────┘ 
src         └─┘           └───────┘       └───────┘      └─┘    └─────┘
typ         └─┘         └───────┘       └───────┘     └─┘   └─────┘ 
doc                       └───────┘       └───────┘      └─┘     └─────┘
1162  mem_closure_of_is_lub (is_lub_cSup hs B) hs
id   └───────────────────┘  └─────────┘ └┘   └┘
src  └───────────────────┘  └─────────┘
typ  └───────────────────┘  └─────────┘ └┘   └┘
1163  
1164  lemma cInf_mem_closure {α : Type u} [topological_space α] [conditionally_complete_linear_order α] [order_topology α]
id                                        └───────────────┘    └─────────────────────────────────┘    └────────────┘ 
src                                       └───────────────┘     └─────────────────────────────────┘     └────────────┘
typ                                       └───────────────┘    └─────────────────────────────────┘    └────────────┘ 
doc                                       └───────────────┘                                             └────────────┘
1165    {s : set α} (hs : s.nonempty) (B : bdd_below s) : Inf s ∈ closure s :=
id          └─┘         └───────┘       └───────┘     └─┘   └─────┘ 
src         └─┘           └───────┘       └───────┘      └─┘    └─────┘
typ         └─┘         └───────┘       └───────┘     └─┘   └─────┘ 
doc                       └───────┘       └───────┘      └─┘     └─────┘
1166  mem_closure_of_is_glb (is_glb_cInf hs B) hs
id   └───────────────────┘  └─────────┘ └┘   └┘
src  └───────────────────┘  └─────────┘
typ  └───────────────────┘  └─────────┘ └┘   └┘
1167  
1168  lemma cSup_mem_of_is_closed {α : Type u} [topological_space α] [conditionally_complete_linear_order α] [order_topology α]
id                                             └───────────────┘    └─────────────────────────────────┘    └────────────┘ 
src                                            └───────────────┘     └─────────────────────────────────┘     └────────────┘
typ                                            └───────────────┘    └─────────────────────────────────┘    └────────────┘ 
doc                                            └───────────────┘                                             └────────────┘
1169    {s : set α} (hs : s.nonempty) (hc : is_closed s) (B : bdd_above s) : Sup s ∈ s :=
id          └─┘         └───────┘        └───────┘        └───────┘     └─┘   
src         └─┘           └───────┘        └───────┘         └───────┘      └─┘   
typ         └─┘         └───────┘        └───────┘        └───────┘     └─┘   
doc                       └───────┘        └───────┘         └───────┘      └─┘
1170  mem_of_is_lub_of_is_closed (is_lub_cSup hs B) hs hc
id   └────────────────────────┘  └─────────┘ └┘   └┘ └┘
src  └────────────────────────┘  └─────────┘
typ  └────────────────────────┘  └─────────┘ └┘   └┘ └┘
1171  
1172  lemma cInf_mem_of_is_closed {α : Type u} [topological_space α] [conditionally_complete_linear_order α] [order_topology α]
id                                             └───────────────┘    └─────────────────────────────────┘    └────────────┘ 
src                                            └───────────────┘     └─────────────────────────────────┘     └────────────┘
typ                                            └───────────────┘    └─────────────────────────────────┘    └────────────┘ 
doc                                            └───────────────┘                                             └────────────┘
1173    {s : set α} (hs : s.nonempty) (hc : is_closed s) (B : bdd_below s) : Inf s ∈ s :=
id          └─┘         └───────┘        └───────┘        └───────┘     └─┘   
src         └─┘           └───────┘        └───────┘         └───────┘      └─┘   
typ         └─┘         └───────┘        └───────┘        └───────┘     └─┘   
doc                       └───────┘        └───────┘         └───────┘      └─┘
1174  mem_of_is_glb_of_is_closed (is_glb_cInf hs B) hs hc
id   └────────────────────────┘  └─────────┘ └┘   └┘ └┘
src  └────────────────────────┘  └─────────┘
typ  └────────────────────────┘  └─────────┘ └┘   └┘ └┘
1175  
1176  /-- A continuous monotone function sends supremum to supremum in conditionally complete
1177  lattices, under a boundedness assumption. -/
1178  lemma cSup_of_cSup_of_monotone_of_continuous {f : α → β} (Mf : continuous f) (Cf : monotone f)
id                                                                └────────┘         └──────┘ 
src                                                                 └────────┘          └──────┘
typ                                                               └────────┘         └──────┘ 
doc                                                                 └────────┘          └──────┘
1179    {s : set α} (ne : s.nonempty) (H : bdd_above s) : f (Sup s) = Sup (f '' s) :=
id          └─┘         └───────┘       └───────┘       └─┘    └─┘   └┘ 
src         └─┘           └───────┘       └───────┘         └─┘     └─┘    └┘
typ         └─┘         └───────┘       └───────┘       └─┘    └─┘   └┘ 
doc                       └───────┘       └───────┘         └─┘      └─┘
1180  begin
st   └─────
1181    refine (is_lub_iff_eq_of_is_lub _).1
id             └─────────────────────┘
src    └─────┘ └─────────────────────┘└─────
typ    └─────┘ └─────────────────────┘└─────
doc    └─────┘                        └─────
txt    └─────┘                        └─────
par    └─────┘                        └─────
pid                                  └─────
st   ───────────────────────────────────────
1182      (is_lub_cSup (ne.image f) (bdd_above_of_bdd_above_of_monotone Cf H)),
id        └─────────┘  └──────┘    └────────────────────────────────┘ └┘ 
src  ───┘ └─────────┘ └──────┘ └┘ └────────────────────────────────┘   └┘
typ  ───┘ └─────────┘ └──────┘└┘ └────────────────────────────────┘└┘└┘
doc  ───┘                      └┘ └────────────────────────────────┘   └┘
txt  ───┘                      └┘                                      └┘
par  ───┘                      └┘                                      └┘
pid  ───┘                      └┘                                      └┘
st   ───────────────────────────────────────────────────────────────────────┘└─
1183    refine is_lub_of_is_lub_of_tendsto (λx hx y hy xy, Cf xy) (is_lub_cSup ne H) ne _,
id            └─────────────────────────┘                 └┘      └─────────┘      └┘
src    └─────┘└─────────────────────────┘  └────────────┘    └┘ └─────────┘   └┘└┘└┘
typ    └─────┘└─────────────────────────┘  └────────────┘└┘  └┘ └─────────┘  └┘└┘└┘
doc    └─────┘                             └────────────┘    └┘               └┘  └┘
txt    └─────┘                             └────────────┘    └┘               └┘  └┘
par    └─────┘                             └────────────┘    └┘               └┘  └┘
pid                                       └────────────┘    └┘               └┘  └┘
st   ──────────────────────────────────────────────────────────────────────────────────┘└─
1184    exact tendsto_le_left inf_le_left (Mf.tendsto _)
id           └─────────────┘ └─────────┘  └────────┘
src    └────┘└─────────────┘└─────────┘ └────────┘└──┘
typ    └────┘└─────────────┘└─────────┘ └────────┘└──┘
doc    └────┘                                     └──┘
txt    └────┘                                     └──┘
par    └────┘                                     └──┘
pid                                              └─┘
st   ──────────────────────────────────────────────────┘
1185  end
st   └─┘
1186  
1187  /-- A continuous monotone function sends indexed supremum to indexed supremum in conditionally complete
1188  lattices, under a boundedness assumption. -/
1189  lemma csupr_of_csupr_of_monotone_of_continuous {f : α → β} {g : γ → α}
id                                                                    
typ                                                                   
1190    (Mf : continuous f) (Cf : monotone f) (H : bdd_above (range g)) : f (supr g) = supr (f ∘ g) :=
id           └────────┘         └──────┘        └───────┘  └───┘        └──┘    └──┘    
src          └────────┘          └──────┘         └───────┘  └───┘          └──┘     └──┘    
typ          └────────┘         └──────┘        └───────┘  └───┘        └──┘    └──┘    
doc          └────────┘          └──────┘         └───────┘  └───┘          └──┘      └──┘
1191  by rw [supr, cSup_of_cSup_of_monotone_of_continuous Mf Cf (range_nonempty _) H, ← range_comp, supr]
id          └──┘  └────────────────────────────────────┘ └┘ └┘  └────────────┘        └────────┘  └──┘
src     └──┘└──┘└┘└────────────────────────────────────┘     └────────────┘└──┘ └──┘└────────┘└┘└──┘└─
typ     └──┘└──┘└┘└────────────────────────────────────┘└┘└┘ └────────────┘└──┘└──┘└────────┘└┘└──┘└─
doc     └──┘└──┘└┘└────────────────────────────────────┘                   └──┘ └──┘          └┘└──┘└─
txt     └──┘    └┘                                                         └──┘ └──┘          └┘    └─
par     └──┘    └┘                                                         └──┘ └──┘          └┘    └─
pid       └┘    └┘                                                         └──┘ └──┘          └┘    
st     └───────┘└─────────────────────────────────────────────────────────────────┘└────────────┘└────┘
1192  
src  
typ  
doc  
txt  
par  
pid  
st   
1193  /-- A continuous monotone function sends infimum to infimum in conditionally complete
1194  lattices, under a boundedness assumption. -/
1195  lemma cInf_of_cInf_of_monotone_of_continuous {f : α → β} (Mf : continuous f) (Cf : monotone f)
id                                                                └────────┘         └──────┘ 
src                                                                 └────────┘          └──────┘
typ                                                               └────────┘         └──────┘ 
doc                                                                 └────────┘          └──────┘
1196    {s : set α} (ne : s.nonempty) (H : bdd_below s) : f (Inf s) = Inf (f '' s) :=
id          └─┘         └───────┘       └───────┘       └─┘    └─┘   └┘ 
src         └─┘           └───────┘       └───────┘         └─┘     └─┘    └┘
typ         └─┘         └───────┘       └───────┘       └─┘    └─┘   └┘ 
doc                       └───────┘       └───────┘         └─┘      └─┘
1197  begin
st   └─────
1198    refine (is_glb_iff_eq_of_is_glb _).1
id             └─────────────────────┘
src    └─────┘ └─────────────────────┘└─────
typ    └─────┘ └─────────────────────┘└─────
doc    └─────┘                        └─────
txt    └─────┘                        └─────
par    └─────┘                        └─────
pid                                  └─────
st   ───────────────────────────────────────
1199      (is_glb_cInf (ne.image _) (bdd_below_of_bdd_below_of_monotone Cf H)),
id        └─────────┘  └──────┘     └────────────────────────────────┘ └┘ 
src  ───┘ └─────────┘ └──────┘└──┘ └────────────────────────────────┘   └┘
typ  ───┘ └─────────┘ └──────┘└──┘ └────────────────────────────────┘└┘└┘
doc  ───┘                     └──┘ └────────────────────────────────┘   └┘
txt  ───┘                     └──┘                                      └┘
par  ───┘                     └──┘                                      └┘
pid  ───┘                     └──┘                                      └┘
st   ───────────────────────────────────────────────────────────────────────┘└─
1200    refine is_glb_of_is_glb_of_tendsto (λx hx y hy xy, Cf xy) (is_glb_cInf ne H) ne _,
id            └─────────────────────────┘                 └┘      └─────────┘      └┘
src    └─────┘└─────────────────────────┘  └────────────┘    └┘ └─────────┘   └┘└┘└┘
typ    └─────┘└─────────────────────────┘  └────────────┘└┘  └┘ └─────────┘  └┘└┘└┘
doc    └─────┘                             └────────────┘    └┘               └┘  └┘
txt    └─────┘                             └────────────┘    └┘               └┘  └┘
par    └─────┘                             └────────────┘    └┘               └┘  └┘
pid                                       └────────────┘    └┘               └┘  └┘
st   ──────────────────────────────────────────────────────────────────────────────────┘└─
1201    exact tendsto_le_left inf_le_left (Mf.tendsto _)
id           └─────────────┘ └─────────┘  └────────┘
src    └────┘└─────────────┘└─────────┘ └────────┘└──┘
typ    └────┘└─────────────┘└─────────┘ └────────┘└──┘
doc    └────┘                                     └──┘
txt    └────┘                                     └──┘
par    └────┘                                     └──┘
pid                                              └─┘
st   ──────────────────────────────────────────────────┘
1202  end
st   └─┘
1203  
1204  /-- A continuous monotone function sends indexed infimum to indexed infimum in conditionally complete
1205  lattices, under a boundedness assumption. -/
1206  lemma cinfi_of_cinfi_of_monotone_of_continuous {f : α → β} {g : γ → α}
id                                                                    
typ                                                                   
1207    (Mf : continuous f) (Cf : monotone f) (H : bdd_below (range g)) : f (infi g) = infi (f ∘ g) :=
id           └────────┘         └──────┘        └───────┘  └───┘        └──┘    └──┘    
src          └────────┘          └──────┘         └───────┘  └───┘          └──┘     └──┘    
typ          └────────┘         └──────┘        └───────┘  └───┘        └──┘    └──┘    
doc          └────────┘          └──────┘         └───────┘  └───┘          └──┘      └──┘
1208  by rw [infi, cInf_of_cInf_of_monotone_of_continuous Mf Cf (range_nonempty _) H, ← range_comp, infi]
id          └──┘  └────────────────────────────────────┘ └┘ └┘  └────────────┘        └────────┘  └──┘
src     └──┘└──┘└┘└────────────────────────────────────┘     └────────────┘└──┘ └──┘└────────┘└┘└──┘└─
typ     └──┘└──┘└┘└────────────────────────────────────┘└┘└┘ └────────────┘└──┘└──┘└────────┘└┘└──┘└─
doc     └──┘└──┘└┘└────────────────────────────────────┘                   └──┘ └──┘          └┘└──┘└─
txt     └──┘    └┘                                                         └──┘ └──┘          └┘    └─
par     └──┘    └┘                                                         └──┘ └──┘          └┘    └─
pid       └┘    └┘                                                         └──┘ └──┘          └┘    
st     └───────┘└─────────────────────────────────────────────────────────────────┘└────────────┘└────┘
1209  
src  
typ  
doc  
txt  
par  
pid  
st   
1210  /-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]`
1211  on a closed subset, contains `a`, and the set `s ∩ [a, b)` has no maximal point, then `b ∈ s`. -/
1212  lemma is_closed.mem_of_ge_of_forall_exists_gt {a b : α} {s : set α} (hs : is_closed (s ∩ Icc a b))
id                                                               └─┘         └───────┘    └─┘  
src                                                               └─┘          └───────┘     └─┘
typ                                                              └─┘         └───────┘    └─┘  
doc                                                                            └───────┘      └─┘
1213    (ha : a ∈ s) (hab : a ≤ b) (hgt : ∀ x ∈ s ∩ Ico a b, (s ∩ Ioc x b).nonempty) :
id                                        └─┘       └─┘   └──────┘
src                                             └─┘          └─┘     └──────┘
typ                                       └─┘       └─┘   └──────┘
doc                                                └─┘           └─┘     └──────┘
1214    b ∈ s :=
id       
src      
typ      
1215  begin
st   └─────
1216    let S := s ∩ Icc a b,
id                └─┘  
src    └───────┘ └─┘ 
typ    └───────┘└─┘
doc    └───────┘  └─┘ 
txt    └───────┘      
par    └───────┘      
pid    └───┘└─┘      
st   ─────────────────────┘└─
1217    replace ha : a ∈ S, from ⟨ha, left_mem_Icc.2 hab⟩,
id                            └┘  └──────────┘   └─┘
src    └───────────┘    └───┘   └┘└──────────┘└─┘   
typ    └───────────┘  └───┘ └┘└┘└──────────┘└─┘└─┘
doc    └───────────┘     └───┘   └┘            └─┘   
txt    └───────────┘     └───┘   └┘            └─┘   
par    └───────────┘     └───┘   └┘            └─┘   
pid           └─┘└─┘     └───┘   └┘            └─┘   
st   ───────────────────┘└─────────────────────────────┘└─
1218    have Sbd : bdd_above S, from ⟨b, λ z hz, hz.2.2⟩,
id                └───────┘         
src    └─────────┘└───────┘   └───┘  └┘ └─────┘  └───┘
typ    └─────────┘└───────┘  └───┘ └┘ └─────┘  └───┘
doc    └─────────┘└───────┘   └───┘  └┘ └─────┘  └───┘
txt    └─────────┘            └───┘  └┘ └─────┘  └───┘
par    └─────────┘            └───┘  └┘ └─────┘  └───┘
pid    └──────┘└─┘            └───┘  └┘ └─────┘  └───┘
st   ───────────────────────┘└────────────────────────┘└─
1219    let c := Sup (s ∩ Icc a b),
id              └─┘     └─┘  
src    └───────┘└─┘   └─┘  
typ    └───────┘└─┘  └─┘
doc    └───────┘└─┘   └─┘  
txt    └───────┘           
par    └───────┘           
pid    └───┘└─┘           
st   ───────────────────────────┘└─
1220    have c_mem : c ∈ S, from cSup_mem_of_is_closed ⟨_, ha⟩ hs Sbd,
id                            └───────────────────┘     └┘  └┘ └─┘
src    └───────────┘     └───┘└───────────────────┘ └─┘  └┘  
typ    └───────────┘   └───┘└───────────────────┘ └─┘└┘└┘└┘└─┘
doc    └───────────┘     └───┘                      └─┘  └┘  
txt    └───────────┘     └───┘                      └─┘  └┘  
par    └───────────┘     └───┘                      └─┘  └┘  
pid    └────────┘└─┘     └───┘                      └─┘  └┘  
st   ───────────────────┘└─────────────────────────────────────────┘└─
1221    have c_le : c ≤ b, from cSup_le ⟨_, ha⟩ (λ x hx, hx.2.2),
id                          └─────┘     └┘
src    └──────────┘    └───┘└─────┘ └─┘  └┘  └─────┘  └───┘
typ    └──────────┘  └───┘└─────┘ └─┘└┘└┘  └─────┘  └───┘
doc    └──────────┘     └───┘        └─┘  └┘  └─────┘  └───┘
txt    └──────────┘     └───┘        └─┘  └┘  └─────┘  └───┘
par    └──────────┘     └───┘        └─┘  └┘  └─────┘  └───┘
pid    └───────┘└─┘     └───┘        └─┘  └┘  └─────┘  └───┘
st   ──────────────────┘└─────────────────────────────────────┘└─
1222    cases eq_or_lt_of_le c_le with hc hc, from hc ▸ c_mem.1,
id           └────────────┘ └──┘                  └┘  └───┘
src    └────┘└────────────┘    └─────────┘  └───┘       └┘
typ    └────┘└────────────┘└──┘└─────────┘  └───┘└┘└───┘└┘
doc    └────┘                  └─────────┘  └───┘        └┘
txt    └────┘                  └─────────┘  └───┘        └┘
par    └────┘                  └─────────┘  └───┘        └┘
pid                           └─────────┘  └───┘        └┘
st   ─────────────────────────────────────┘└─────────────────┘└─
1223    exfalso,
src    └─────┘
typ    └─────┘
doc    └─────┘
txt    └─────┘
par    └─────┘
st   ────────┘└─
1224    rcases hgt c ⟨c_mem.1, c_mem.2.1, hc⟩ with ⟨x, xs, cx, xb⟩,
id            └─┘            └───┘      └┘
src    └─────┘          └──┘     └────┘  └────────────────────┘
typ    └─────┘└─┘      └──┘└───┘└────┘└┘└────────────────────┘
doc    └─────┘          └──┘     └────┘  └────────────────────┘
txt    └─────┘          └──┘     └────┘  └────────────────────┘
par    └─────┘          └──┘     └────┘  └────────────────────┘
pid                    └──┘     └────┘  └────────────────────┘
st   ───────────────────────────────────────────────────────────┘└─
1225    exact not_lt_of_le (le_cSup Sbd ⟨xs, le_trans (le_cSup Sbd ha) (le_of_lt cx), xb⟩) cx
id           └──────────┘               └┘  └──────┘  └─────┘ └─┘ └┘   └──────┘      └┘   └┘
src    └────┘└──────────┘              └┘└──────┘ └─────┘     └┘ └──────┘  └─┘  └─┘  
typ    └────┘└──────────┘            └┘└┘└──────┘ └─────┘└─┘└┘└┘ └──────┘  └─┘└┘└─┘└┘
doc    └────┘                          └┘                     └┘           └─┘  └─┘  
txt    └────┘                          └┘                     └┘           └─┘  └─┘  
par    └────┘                          └┘                     └┘           └─┘  └─┘  
pid                                   └┘                     └┘           └─┘  └─┘  
st   ───────────────────────────────────────────────────────────────────────────────────────┘
1226  end
st   └─┘
1227  
1228  /-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]`
1229  on a closed subset, contains `a`, and for any `a ≤ x < y ≤ b`, `x ∈ s`, the set `s ∩ (x, y]`
1230  is not empty, then `[a, b] ⊆ s`. -/
1231  lemma is_closed.Icc_subset_of_forall_exists_gt {a b : α} {s : set α} (hs : is_closed (s ∩ Icc a b))
id                                                                └─┘         └───────┘    └─┘  
src                                                                └─┘          └───────┘     └─┘
typ                                                               └─┘         └───────┘    └─┘  
doc                                                                             └───────┘      └─┘
1232    (ha : a ∈ s) (hgt : ∀ x ∈ s ∩ Ico a b, ∀ y ∈ Ioi x,  (s ∩ Ioc x y).nonempty) :
id                             └─┘         └─┘       └─┘   └──────┘
src                                └─┘            └─┘         └─┘     └──────┘
typ                            └─┘         └─┘       └─┘   └──────┘
doc                                  └─┘            └─┘          └─┘     └──────┘
1233    Icc a b ⊆ s :=
id     └─┘    
src    └─┘     
typ    └─┘    
doc    └─┘
1234  begin
st   └─────
1235    assume y hy,
src    └─────────┘
typ    └─────────┘
doc    └─────────┘
txt    └─────────┘
par    └─────────┘
pid    └─────────┘
st   ────────────┘└─
1236    have : is_closed (s ∩ Icc a y),
id            └───────┘    └─┘  
src    └─────┘└───────┘  └─┘  
typ    └─────┘└───────┘ └─┘
doc    └─────┘└───────┘   └─┘  
txt    └─────┘                 
par    └─────┘                 
pid    └───┘└┘                 
st   ───────────────────────────────┘└─
1237    { suffices : s ∩ Icc a y = s ∩ Icc a b ∩ Icc a y,
id                                           └─┘  
src      └─────────┘               └─┘ 
typ      └─────────┘             └─┘
doc      └─────────┘                └─┘ 
txt      └─────────┘                    
par      └─────────┘                    
pid      └───────┘└┘                    
st   ───┘└────────────────────────────────────────────┘└─
1238      { rw this, exact is_closed_inter hs is_closed_Icc },
id            └──┘        └─────────────┘ └┘ └───────────┘
src        └─┘      └────┘└─────────────┘  └───────────┘
typ        └─┘└──┘  └────┘└─────────────┘└┘└───────────┘
doc        └─┘      └────┘                              
txt        └─┘      └────┘                              
par        └─┘      └────┘                              
pid                                                   
st   ─────┘└─────┘└───────────────────────────────────────┘└┘
1239      rw [inter_assoc],
id           └─────────┘
src      └──┘└─────────┘
typ      └──┘└─────────┘
doc      └──┘           
txt      └──┘           
par      └──┘           
pid        └┘           
st   ──────────────────┘└──
1240      congr,
src      └───┘
typ      └───┘
txt      └───┘
par      └───┘
st   ────────┘└─
1241      exact (inter_eq_self_of_subset_right $ Icc_subset_Icc_right hy.2).symm },
id              └───────────────────────────┘   └──────────────────┘ └┘
src      └────┘ └───────────────────────────┘ └──────────────────┘  └───────┘
typ      └────┘ └───────────────────────────┘ └──────────────────┘└┘└───────┘
doc      └────┘                                                     └───────┘
txt      └────┘                                                     └───────┘
par      └────┘                                                     └───────┘
pid                                                                └─────┘└┘
st   ──────────────────────────────────────────────────────────────────────────┘└┘
1242    exact is_closed.mem_of_ge_of_forall_exists_gt this ha hy.1
id           └─────────────────────────────────────┘ └──┘ └┘
src    └────┘└─────────────────────────────────────┘        └──
typ    └────┘└─────────────────────────────────────┘└──┘└┘  └──
doc    └────┘└─────────────────────────────────────┘        └──
txt    └────┘                                               └──
par    └────┘                                               └──
pid                                                        └──
st   ─────────────────────────────────────────────────────────────
1243      (λ x hx, hgt x ⟨hx.1, Ico_subset_Ico_right hy.2 hx.2⟩ y hx.2.2)
id                └─┘          └──────────────────┘ └┘         
src  ───┘  └─────┘       └──┘└──────────────────┘  └─┘  └──┘   └────┘
typ  ───┘  └─────┘└─┘    └──┘└──────────────────┘└┘└─┘  └──┘  └────┘
doc  ───┘  └─────┘       └──┘                      └─┘  └──┘   └────┘
txt  ───┘  └─────┘       └──┘                      └─┘  └──┘   └────┘
par  ───┘  └─────┘       └──┘                      └─┘  └──┘   └────┘
pid  ───┘  └─────┘       └──┘                      └─┘  └──┘   └───┘
st   ───────────────────────────────────────────────────────────────────┘
1244  end
st   └─┘
1245  
1246  section densely_ordered
1247  
1248  variables [densely_ordered α] {a b : α}
id              └─────────────┘
src             └─────────────┘
typ             └─────────────┘
doc             └─────────────┘
1249  
1250  /-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]`
1251  on a closed subset, contains `a`, and for any `x ∈ s ∩ [a, b)` the set `s` includes some open
1252  neighborhood of `x` within `(x, +∞)`, then `[a, b] ⊆ s`. -/
1253  lemma is_closed.Icc_subset_of_forall_mem_nhds_within {a b : α} {s : set α}
id                                                                      └─┘ 
src                                                                      └─┘
typ                                                                     └─┘ 
1254    (hs : is_closed (s ∩ Icc a b)) (ha : a ∈ s)
id           └───────┘    └─┘             
src          └───────┘     └─┘               
typ          └───────┘    └─┘             
doc          └───────┘      └─┘
1255    (hgt : ∀ x ∈ s ∩ Ico a b, s ∈ nhds_within x (Ioi x)) :
id                   └─┘      └─────────┘   └─┘ 
src                    └─┘         └─────────┘    └─┘
typ                  └─┘      └─────────┘   └─┘ 
doc                     └─┘          └─────────┘    └─┘
1256    Icc a b ⊆ s :=
id     └─┘    
src    └─┘     
typ    └─┘    
doc    └─┘
1257  begin
st   └─────
1258    apply hs.Icc_subset_of_forall_exists_gt ha,
id           └───────────────────────────────┘ └┘
src    └────┘└───────────────────────────────┘
typ    └────┘└───────────────────────────────┘└┘
doc    └────┘└───────────────────────────────┘
txt    └────┘                                 
par    └────┘                                 
pid                                          
st   ───────────────────────────────────────────┘└─
1259    rintros x ⟨hxs, hxab⟩ y hyxb,
src    └──────────────────────────┘
typ    └──────────────────────────┘
doc    └──────────────────────────┘
txt    └──────────────────────────┘
par    └──────────────────────────┘
pid           └───────────────────┘
st   ─────────────────────────────┘└─
1260    have : s ∩ Ioc x y ∈ nhds_within x (Ioi x),
id              └─┘     └─────────┘    └─┘ 
src    └─────┘ └─┘  └─────────┘  └─┘ 
typ    └─────┘└─┘ └─────────┘  └─┘
doc    └─────┘  └─┘   └─────────┘  └─┘ 
txt    └─────┘                         
par    └─────┘                         
pid    └───┘└┘                         
st   ───────────────────────────────────────────┘└─
1261      from inter_mem_sets (hgt x ⟨hxs, hxab⟩) (Ioc_mem_nhds_within_Ioi ⟨le_refl _, hyxb⟩),
id            └────────────┘  └─┘   └─┘  └──┘    └─────────────────────┘  └─────┘    └──┘
src      └───┘└────────────┘         └┘    └─┘ └─────────────────────┘ └─────┘└──┘    └┘
typ      └───┘└────────────┘ └─┘ └─┘└┘└──┘└─┘ └─────────────────────┘ └─────┘└──┘└──┘└┘
doc      └───┘                       └┘    └─┘                                └──┘    └┘
txt      └───┘                       └┘    └─┘                                └──┘    └┘
par      └───┘                       └┘    └─┘                                └──┘    └┘
pid      └───┘                       └┘    └─┘                                └──┘    └┘
st   ──────────────────────────────────────────────────────────────────────────────────────┘└─
1262    exact nonempty_of_mem_sets (nhds_within_Ioi_self_ne_bot' hxab.2) this
id           └──────────────────┘  └──────────────────────────┘ └──┘    └──┘
src    └────┘└──────────────────┘ └──────────────────────────┘    └──┘    
typ    └────┘└──────────────────┘ └──────────────────────────┘└──┘└──┘└──┘
doc    └────┘                                                     └──┘    
txt    └────┘                                                     └──┘    
par    └────┘                                                     └──┘    
pid                                                              └──┘    
st   ───────────────────────────────────────────────────────────────────────┘
1263  end
st   └─┘
1264  
1265  /-- A closed interval is connected. -/
1266  lemma is_connected_Icc : is_connected (Icc a b) :=
id                            └──────────┘  └─┘  
src                           └──────────┘  └─┘
typ                           └──────────┘  └─┘  
doc                           └──────────┘  └─┘
1267  is_connected_closed_iff.2
id   └─────────────────────┘
src  └─────────────────────┘
typ  └─────────────────────┘
1268  begin
st   └─────
1269    rintros s t hs ht hab ⟨x, hx⟩ ⟨y, hy⟩,
src    └───────────────────────────────────┘
typ    └───────────────────────────────────┘
doc    └───────────────────────────────────┘
txt    └───────────────────────────────────┘
par    └───────────────────────────────────┘
pid           └────────────────────────────┘
st   ──────────────────────────────────────┘└─
1270    wlog hxy : x ≤ y := le_total x y using [x y s t, y x t s],
id                      └──────┘  
src    └─────────┘  └──┘└──────┘  └───────────────────────┘
typ    └─────────┘└──┘└──────┘└───────────────────────┘
doc    └─────────┘   └──┘          └───────────────────────┘
txt    └─────────┘   └──┘          └───────────────────────┘
par    └─────────┘   └──┘          └───────────────────────┘
pid        └──┘└─┘   └──┘          └───────────────────────┘
st   ──────────────────────────────────────────────────────────┘└─
1271    have xyab : Icc x y ⊆ Icc a b := Icc_subset_Icc hx.1.1 hy.1.2,
id                        └─┘      └────────────┘ └┘     └┘
src    └──────────┘     └─┘  └──┘└────────────┘  └───┘  └──┘
typ    └──────────┘   └─┘└──┘└────────────┘└┘└───┘└┘└──┘
doc    └──────────┘      └─┘  └──┘                └───┘  └──┘
txt    └──────────┘           └──┘                └───┘  └──┘
par    └──────────┘           └──┘                └───┘  └──┘
pid    └───────┘└─┘           └──┘                └───┘  └┘└┘
st   ──────────────────────────────────────────────────────────────┘└─
1272    by_contradiction hst,
src    └──────────────────┘
typ    └──────────────────┘
doc    └──────────────────┘
txt    └──────────────────┘
par    └──────────────────┘
pid                    └──┘
st   ─────────────────────┘└─
1273    suffices : Icc x y ⊆ s,
id                └─┘     
src    └─────────┘└─┘   
typ    └─────────┘└─┘ 
doc    └─────────┘└─┘   
txt    └─────────┘      
par    └─────────┘      
pid    └───────┘└┘      
st   ───────────────────────┘└─
1274      from hst ⟨y, xyab $ right_mem_Icc.2 hxy, this $ right_mem_Icc.2 hxy, hy.2⟩,
id            └─┘    └──┘                        └──┘   └───────────┘   └─┘  └┘
src      └───┘     └┘                  └─┘   └┘     └───────────┘└─┘   └┘  └─┘
typ      └───┘└─┘ └┘└──┘              └─┘   └┘└──┘ └───────────┘└─┘└─┘└┘└┘└─┘
doc      └───┘     └┘                  └─┘   └┘                  └─┘   └┘  └─┘
txt      └───┘     └┘                  └─┘   └┘                  └─┘   └┘  └─┘
par      └───┘     └┘                  └─┘   └┘                  └─┘   └┘  └─┘
pid      └───┘     └┘                  └─┘   └┘                  └─┘   └┘  └─┘
st   ─────────────────────────────────────────────────────────────────────────────┘└─
1275    apply (is_closed_inter hs is_closed_Icc).Icc_subset_of_forall_mem_nhds_within hx.2,
id            └─────────────┘ └┘ └───────────┘                                       └┘
src    └────┘ └─────────────┘  └───────────┘└─────────────────────────────────────┘  └┘
typ    └────┘ └─────────────┘└┘└───────────┘└─────────────────────────────────────┘└┘└┘
doc    └────┘                               └─────────────────────────────────────┘  └┘
txt    └────┘                               └─────────────────────────────────────┘  └┘
par    └────┘                               └─────────────────────────────────────┘  └┘
pid                                        └─────────────────────────────────────┘  └┘
st   ───────────────────────────────────────────────────────────────────────────────────┘└─
1276    rintros z ⟨zs, hz⟩,
src    └────────────────┘
typ    └────────────────┘
doc    └────────────────┘
txt    └────────────────┘
par    └────────────────┘
pid           └─────────┘
st   ───────────────────┘└─
1277    have zt : z ∈ -t, from λ zt, hst ⟨z, xyab $ Ico_subset_Icc_self hz, zs, zt⟩,
id                              └─┘    └──┘   └─────────────────┘ └┘  └┘
src    └────────┘    └───┘ └───┘     └┘     └─────────────────┘  └┘  └┘  
typ    └────────┘  └───┘ └───┘└─┘ └┘└──┘ └─────────────────┘└┘└┘└┘└┘  
doc    └────────┘      └───┘ └───┘     └┘                          └┘  └┘  
txt    └────────┘      └───┘ └───┘     └┘                          └┘  └┘  
par    └────────┘      └───┘ └───┘     └┘                          └┘  └┘  
pid    └─────┘└─┘      └───┘ └───┘     └┘                          └┘  └┘  
st   ─────────────────┘└─────────────────────────────────────────────────────────┘└─
1278    have : -t ∩ Ioc z y ∈ nhds_within z (Ioi z),
id               └─┘      └─────────┘    └─┘ 
src    └─────┘  └─┘   └─────────┘  └─┘ 
typ    └─────┘ └─┘  └─────────┘  └─┘
doc    └─────┘   └─┘   └─────────┘  └─┘ 
txt    └─────┘                          
par    └─────┘                          
pid    └───┘└┘                          
st   ────────────────────────────────────────────┘└─
1279    { rw [← nhds_within_Ioc_eq_nhds_within_Ioi hz.2],
id             └────────────────────────────────┘ └┘
src      └────┘└────────────────────────────────┘  └─┘
typ      └────┘└────────────────────────────────┘└┘└─┘
doc      └────┘                                    └─┘
txt      └────┘                                    └─┘
par      └────┘                                    └─┘
pid        └──┘                                    └─┘
st   ───┘└─────────────────────────────────────────┘└────
1280      exact mem_nhds_within.2 ⟨-t, ht, zt, subset.refl _⟩},
id             └─────────────┘       └┘  └┘  └─────────┘
src      └────┘└─────────────┘└─┘   └┘  └┘  └┘└─────────┘└─┘
typ      └────┘└─────────────┘└─┘  └┘└┘└┘└┘└┘└─────────┘└─┘
doc      └────┘               └─┘   └┘  └┘  └┘           └─┘
txt      └────┘               └─┘   └┘  └┘  └┘           └─┘
par      └────┘               └─┘   └┘  └┘  └┘           └─┘
pid                          └─┘   └┘  └┘  └┘           └─┘
st   ──────────────────────────────────────────────────────┘└┘
1281    apply mem_sets_of_superset this,
id           └──────────────────┘ └──┘
src    └────┘└──────────────────┘
typ    └────┘└──────────────────┘└──┘
doc    └────┘                    
txt    └────┘                    
par    └────┘                    
pid                             
st   ────────────────────────────────┘└─
1282    have : Ioc z y ⊆ s ∪ t, from λ w hw, hab (xyab ⟨le_trans hz.1 (le_of_lt hw.1), hw.2⟩),
id            └─┘                      └─┘  └──┘  └──────┘ └┘    └──────┘
src    └─────┘└─┘       └───┘ └─────┘         └──────┘  └─┘ └──────┘  └───┘  └──┘
typ    └─────┘└─┘   └───┘ └─────┘└─┘ └──┘ └──────┘└┘└─┘ └──────┘  └───┘  └──┘
doc    └─────┘└─┘        └───┘ └─────┘                   └─┘           └───┘  └──┘
txt    └─────┘           └───┘ └─────┘                   └─┘           └───┘  └──┘
par    └─────┘           └───┘ └─────┘                   └─┘           └───┘  └──┘
pid    └───┘└┘           └───┘ └─────┘                   └─┘           └───┘  └──┘
st   ───────────────────────┘└─────────────────────────────────────────────────────────────┘└─
1283    exact λ w ⟨wt, wzy⟩, (this wzy).elim id (λ h, (wt h).elim)
id                └┘  └─┘    └──┘           └┘
src    └────┘ └──┘  └┘   └─┘        └─────┘└┘  └──┘    └──────┘
typ    └────┘ └──┘└┘└┘└─┘└─┘ └──┘   └─────┘└┘  └──┘    └──────┘
doc    └────┘ └──┘  └┘   └─┘        └─────┘    └──┘    └──────┘
txt    └────┘ └──┘  └┘   └─┘        └─────┘    └──┘    └──────┘
par    └────┘ └──┘  └┘   └─┘        └─────┘    └──┘    └──────┘
pid          └──┘  └┘   └─┘        └─────┘    └──┘    └─────┘
st   ────────────────────────────────────────────────────────────┘
1284  end
st   └─┘
1285  
1286  lemma is_connected_iff_forall_Icc_subset {s : set α} :
id                                                 └─┘ 
src                                                └─┘
typ                                                └─┘ 
1287    is_connected s ↔ ∀ x y ∈ s, x ≤ y → Icc x y ⊆ s :=
id     └──────────┘                └─┘    
src    └──────────┘                      └─┘     
typ    └──────────┘                └─┘    
doc    └──────────┘                        └─┘
1288  ⟨λ h x y hx hy hxy, h.forall_Icc_subset hx hy, λ h, is_connected_of_forall_pair $ λ x y hx hy,
id         └┘ └┘ └─┘  └────────────────┘ └┘ └┘      └─────────────────────────┘       └┘ └┘
src                       └────────────────┘             └─────────────────────────┘
typ        └┘ └┘ └─┘  └────────────────┘ └┘ └┘      └─────────────────────────┘       └┘ └┘
doc                                                      └─────────────────────────┘
1289    ⟨Icc (min x y) (max x y), h (min x y) (max x y)
id      └─┘  └─┘     └─┘       └─┘     └─┘  
src     └─┘  └─┘       └─┘          └─┘       └─┘
typ     └─┘  └─┘     └─┘       └─┘     └─┘  
doc     └─┘
1290      ((min_choice x y).elim (λ h', by rwa h') (λ h', by rwa h'))
id         └────────┘   └──┘     └┘         └┘     └┘         └┘
src        └────────┘     └──┘            └──┘              └──┘
typ        └────────┘   └──┘     └┘     └──┘└┘     └┘     └──┘└┘
doc                                       └──┘              └──┘
txt                                       └──┘              └──┘
par                                       └──┘              └──┘
pid                                                           
st                                       └─────┘           └─────┘
1291      ((max_choice x y).elim (λ h', by rwa h') (λ h', by rwa h')) min_le_max,
id         └────────┘   └──┘     └┘         └┘     └┘         └┘   └────────┘
src        └────────┘     └──┘            └──┘              └──┘     └────────┘
typ        └────────┘   └──┘     └┘     └──┘└┘     └┘     └──┘└┘   └────────┘
doc                                       └──┘              └──┘
txt                                       └──┘              └──┘
par                                       └──┘              └──┘
pid                                                           
st                                       └─────┘           └─────┘
1292      ⟨min_le_left x y, le_max_left x y⟩, ⟨min_le_right x y, le_max_right x y⟩, is_connected_Icc⟩⟩
id        └─────────┘    └─────────┘      └──────────┘    └──────────┘     └──────────────┘
src       └─────────┘      └─────────┘        └──────────┘      └──────────┘       └──────────────┘
typ       └─────────┘    └─────────┘      └──────────┘    └──────────┘     └──────────────┘
doc                                                                                └──────────────┘
1293  
1294  lemma is_connected_Ici : is_connected (Ici a) :=
id                            └──────────┘  └─┘ 
src                           └──────────┘  └─┘
typ                           └──────────┘  └─┘ 
doc                           └──────────┘  └─┘
1295  is_connected_iff_forall_Icc_subset.2 $ λ x y hx hy hxy, (Icc_subset_Ici_iff hxy).2 hx
id   └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘   └┘
src  └────────────────────────────────┘                      └────────────────┘     
typ  └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘   └┘
1296  
1297  lemma is_connected_Iic : is_connected (Iic a) :=
id                            └──────────┘  └─┘ 
src                           └──────────┘  └─┘
typ                           └──────────┘  └─┘ 
doc                           └──────────┘  └─┘
1298  is_connected_iff_forall_Icc_subset.2 $ λ x y hx hy hxy, (Icc_subset_Iic_iff hxy).2 hy
id   └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘   └┘
src  └────────────────────────────────┘                      └────────────────┘     
typ  └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘   └┘
1299  
1300  lemma is_connected_Iio : is_connected (Iio a) :=
id                            └──────────┘  └─┘ 
src                           └──────────┘  └─┘
typ                           └──────────┘  └─┘ 
doc                           └──────────┘  └─┘
1301  is_connected_iff_forall_Icc_subset.2 $ λ x y hx hy hxy, (Icc_subset_Iio_iff hxy).2 hy
id   └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘   └┘
src  └────────────────────────────────┘                      └────────────────┘     
typ  └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘   └┘
1302  
1303  lemma is_connected_Ioi : is_connected (Ioi a) :=
id                            └──────────┘  └─┘ 
src                           └──────────┘  └─┘
typ                           └──────────┘  └─┘ 
doc                           └──────────┘  └─┘
1304  is_connected_iff_forall_Icc_subset.2 $ λ x y hx hy hxy, (Icc_subset_Ioi_iff hxy).2 hx
id   └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘   └┘
src  └────────────────────────────────┘                      └────────────────┘     
typ  └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘   └┘
1305  
1306  lemma is_connected_Ioo : is_connected (Ioo a b) :=
id                            └──────────┘  └─┘  
src                           └──────────┘  └─┘
typ                           └──────────┘  └─┘  
doc                           └──────────┘  └─┘
1307  is_connected_iff_forall_Icc_subset.2 $ λ x y hx hy hxy, (Icc_subset_Ioo_iff hxy).2 ⟨hx.1, hy.2⟩
id   └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘    └┘   └┘
src  └────────────────────────────────┘                      └────────────────┘               
typ  └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘    └┘   └┘
1308  
1309  lemma is_connected_Ioc : is_connected (Ioc a b) :=
id                            └──────────┘  └─┘  
src                           └──────────┘  └─┘
typ                           └──────────┘  └─┘  
doc                           └──────────┘  └─┘
1310  is_connected_iff_forall_Icc_subset.2 $ λ x y hx hy hxy, (Icc_subset_Ioc_iff hxy).2 ⟨hx.1, hy.2⟩
id   └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘    └┘   └┘
src  └────────────────────────────────┘                      └────────────────┘               
typ  └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘    └┘   └┘
1311  
1312  lemma is_connected_Ico : is_connected (Ico a b) :=
id                            └──────────┘  └─┘  
src                           └──────────┘  └─┘
typ                           └──────────┘  └─┘  
doc                           └──────────┘  └─┘
1313  is_connected_iff_forall_Icc_subset.2 $ λ x y hx hy hxy, (Icc_subset_Ico_iff hxy).2 ⟨hx.1, hy.2⟩
id   └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘    └┘   └┘
src  └────────────────────────────────┘                      └────────────────┘               
typ  └────────────────────────────────┘        └┘ └┘ └─┘   └────────────────┘ └─┘    └┘   └┘
1314  
1315  @[priority 100]
1316  instance ordered_connected_space : connected_space α :=
id                                      └─────────────┘ 
src                                     └─────────────┘
typ                                     └─────────────┘ 
doc                                     └─────────────┘
1317  ⟨is_connected_iff_forall_Icc_subset.2 $ λ x y hx hy hxy, subset_univ _⟩
id    └────────────────────────────────┘        └┘ └┘ └─┘  └─────────┘
src   └────────────────────────────────┘                     └─────────┘
typ   └────────────────────────────────┘        └┘ └┘ └─┘  └─────────┘
1318  
1319  /--Intermediate Value Theorem for continuous functions on closed intervals, case `f a ≤ t ≤ f b`.-/
1320  lemma intermediate_value_Icc {a b : α} (hab : a ≤ b) {f : α → β} (hf : continuous_on f (Icc a b)) :
id                                                                    └───────────┘   └─┘  
src                                                                        └───────────┘    └─┘
typ                                                                   └───────────┘   └─┘  
doc                                                                         └───────────┘    └─┘
1321    Icc (f a) (f b) ⊆ f '' (Icc a b) :=
id     └─┘           └┘  └─┘  
src    └─┘                └┘  └─┘
typ    └─┘           └┘  └─┘  
doc    └─┘                     └─┘
1322  is_connected_Icc.intermediate_value (left_mem_Icc.2 hab) (right_mem_Icc.2 hab) hf
id   └──────────────┘└─────────────────┘  └──────────┘  └─┘   └───────────┘  └─┘  └┘
src  └──────────────┘└─────────────────┘  └──────────┘        └───────────┘
typ  └──────────────┘└─────────────────┘  └──────────┘  └─┘   └───────────┘  └─┘  └┘
doc  └──────────────┘└─────────────────┘
1323  
1324  /--Intermediate Value Theorem for continuous functions on closed intervals, case `f a ≥ t ≥ f b`.-/
1325  lemma intermediate_value_Icc' {a b : α} (hab : a ≤ b) {f : α → β} (hf : continuous_on f (Icc a b)) :
id                                                                     └───────────┘   └─┘  
src                                                                         └───────────┘    └─┘
typ                                                                    └───────────┘   └─┘  
doc                                                                          └───────────┘    └─┘
1326    Icc (f b) (f a) ⊆ f '' (Icc a b) :=
id     └─┘           └┘  └─┘  
src    └─┘                └┘  └─┘
typ    └─┘           └┘  └─┘  
doc    └─┘                     └─┘
1327  is_connected_Icc.intermediate_value (right_mem_Icc.2 hab) (left_mem_Icc.2 hab) hf
id   └──────────────┘└─────────────────┘  └───────────┘  └─┘   └──────────┘  └─┘  └┘
src  └──────────────┘└─────────────────┘  └───────────┘        └──────────┘
typ  └──────────────┘└─────────────────┘  └───────────┘  └─┘   └──────────┘  └─┘  └┘
doc  └──────────────┘└─────────────────┘
1328  
1329  end densely_ordered
1330  
1331  /-- The extreme value theorem: a continuous function realizes its minimum on a compact set -/
1332  lemma compact.exists_forall_le {α : Type u} [topological_space α]
id                                                └───────────────┘ 
src                                               └───────────────┘
typ                                               └───────────────┘ 
doc                                               └───────────────┘
1333    {s : set α} (hs : compact s) (ne_s : s.nonempty) {f : α → β} (hf : continuous_on f s) :
id          └─┘         └─────┘           └───────┘                  └───────────┘  
src         └─┘          └─────┘             └───────┘                    └───────────┘
typ         └─┘         └─────┘           └───────┘                  └───────────┘  
doc                      └─────┘             └───────┘                    └───────────┘
1334    ∃x∈s, ∀y∈s, f x ≤ f y :=
id               
src                  
typ              
1335  begin
st   └─────
1336    have C : compact (f '' s) := hs.image_of_continuous_on hf,
id              └─────┘   └┘      └───────────────────────┘ └┘
src    └───────┘└─────┘  └┘ └───┘└───────────────────────┘
typ    └───────┘└─────┘ └┘└───┘└───────────────────────┘└┘
doc    └───────┘└─────┘     └───┘                         
txt    └───────┘            └───┘                         
par    └───────┘            └───┘                         
pid    └────┘└─┘            └──┘                         
st   ──────────────────────────────────────────────────────────┘└─
1337    haveI := has_Inf_to_nonempty β,
id              └─────────────────┘ 
src    └───────┘└─────────────────┘
typ    └───────┘└─────────────────┘
doc    └───────┘                   
txt    └───────┘                   
par    └───────┘                   
pid         └─┘                   
st   ───────────────────────────────┘└─
1338    have B : bdd_below (f '' s) := bdd_below_of_compact C,
id              └───────┘           └──────────────────┘ 
src    └───────┘└───────┘     └───┘└──────────────────┘
typ    └───────┘└───────┘   └───┘└──────────────────┘
doc    └───────┘└───────┘     └───┘└──────────────────┘
txt    └───────┘              └───┘                    
par    └───────┘              └───┘                    
pid    └────┘└─┘              └──┘                    
st   ──────────────────────────────────────────────────────┘└─
1339    have : Inf (f '' s) ∈ f '' s :=
id            └─┘               
src    └─────┘└─┘     └┘    └───
typ    └─────┘└─┘     └┘  └───
doc    └─────┘└─┘     └┘     └───
txt    └─────┘        └┘     └───
par    └─────┘        └┘     └───
pid    └───┘└┘        └┘     └───
st   ──────────────────────────────────
1340      cInf_mem_of_is_closed (ne_s.image _) (closed_of_compact _ C) B,
id       └───────────────────┘  └────────┘     └───────────────┘     
src  ───┘└───────────────────┘ └────────┘└──┘ └───────────────┘└─┘ └┘
typ  ───┘└───────────────────┘ └────────┘└──┘ └───────────────┘└─┘└┘
doc  ───┘                                └──┘                  └─┘ └┘
txt  ───┘                                └──┘                  └─┘ └┘
par  ───┘                                └──┘                  └─┘ └┘
pid  ───┘                                └──┘                  └─┘ └┘
st   ─────────────────────────────────────────────────────────────────┘└─
1341    rcases (mem_image _ _ _).1 this with ⟨x, xs, hx⟩,
id             └───────┘          └──┘
src    └─────┘ └───────┘└────────┘    └───────────────┘
typ    └─────┘ └───────┘└────────┘└──┘└───────────────┘
doc    └─────┘          └────────┘    └───────────────┘
txt    └─────┘          └────────┘    └───────────────┘
par    └─────┘          └────────┘    └───────────────┘
pid                    └────────┘    └───────────────┘
st   ─────────────────────────────────────────────────┘└─
1342    exact ⟨x, xs, λ y hy, hx.symm ▸ cInf_le B ⟨_, hy, rfl⟩⟩
id              └┘          └─────┘  └─────┘          └─┘
src    └────┘  └┘  └┘ └─────┘└─────┘└─────┘  └─┘  └┘└─┘└─┘
typ    └────┘ └┘└┘└┘ └─────┘└─────┘└─────┘ └─┘  └┘└─┘└─┘
doc    └────┘  └┘  └┘ └─────┘                 └─┘  └┘   └─┘
txt    └────┘  └┘  └┘ └─────┘                 └─┘  └┘   └─┘
par    └────┘  └┘  └┘ └─────┘                 └─┘  └┘   └─┘
pid           └┘  └┘ └─────┘                 └─┘  └┘   └┘
st   ─────────────────────────────────────────────────────────┘
1343  end
st   └─┘
1344  
1345  /-- The extreme value theorem: a continuous function realizes its maximum on a compact set -/
1346  lemma compact.exists_forall_ge {α : Type u} [topological_space α]:
id                                                └───────────────┘ 
src                                               └───────────────┘
typ                                               └───────────────┘ 
doc                                               └───────────────┘
1347    ∀ {s : set α}, compact s → s.nonempty → ∀ {f : α → β}, continuous_on f s →
id            └─┘    └─────┘    └───────┘               └───────────┘  
src           └─┘     └─────┘      └───────┘                  └───────────┘
typ           └─┘    └─────┘    └───────┘               └───────────┘  
doc                   └─────┘      └───────┘                  └───────────┘
1348    ∃x∈s, ∀y∈s, f y ≤ f x :=
id               
src                  
typ              
1349  @compact.exists_forall_le (order_dual β) _ _ _ _ _
id    └──────────────────────┘  └────────┘ 
src   └──────────────────────┘  └────────┘
typ   └──────────────────────┘  └────────┘ 
doc   └──────────────────────┘  └────────┘
1350  
1351  end conditionally_complete_linear_order
1352  
1353  
1354  section liminf_limsup
1355  
1356  section order_closed_topology
1357  variables [semilattice_sup α] [topological_space α] [order_topology α]
id              └─────────────┘     └───────────────┘     └────────────┘
src             └─────────────┘     └───────────────┘     └────────────┘
typ             └─────────────┘     └───────────────┘     └────────────┘
doc             └─────────────┘     └───────────────┘     └────────────┘
1358  
1359  lemma is_bounded_le_nhds (a : α) : (𝓝 a).is_bounded (≤) :=
id                                        └────────┘  
src                                         └────────┘  
typ                                       └────────┘  
doc                                         └────────┘
1360  match forall_le_or_exists_lt_sup a with
id         └────────────────────────┘ 
src        └────────────────────────┘
typ        └────────────────────────┘ 
1361  | or.inl h := ⟨a, eventually_of_forall _ h⟩
id     └────┘        └──────────────────┘
src    └────┘          └──────────────────┘
typ    └────┘        └──────────────────┘
1362  | or.inr ⟨b, hb⟩ := ⟨b, ge_mem_nhds hb⟩
id     └────┘    └┘         └─────────┘
src    └────┘                └─────────┘
typ    └────┘    └┘         └─────────┘
1363  end
1364  
1365  lemma is_bounded_under_le_of_tendsto {f : filter β} {u : β → α} {a : α}
id                                             └────┘                  
src                                            └────┘
typ                                            └────┘                  
1366    (h : tendsto u f (𝓝 a)) : f.is_bounded_under (≤) u :=
id          └─────┘          └───────────────┘    
src         └─────┘              └───────────────┘ 
typ         └─────┘          └───────────────┘    
doc         └─────┘      
1367  is_bounded_of_le h (is_bounded_le_nhds a)
id   └──────────────┘   └────────────────┘ 
src  └──────────────┘    └────────────────┘
typ  └──────────────┘   └────────────────┘ 
1368  
1369  @[nolint] -- see Note [nolint_ge]
doc    └────┘
1370  lemma is_cobounded_ge_nhds (a : α) : (𝓝 a).is_cobounded (≥) :=
id                                          └──────────┘  
src                                           └──────────┘  
typ                                         └──────────┘  
doc                                           └──────────┘
1371  is_cobounded_of_is_bounded nhds_ne_bot (is_bounded_le_nhds a)
id   └────────────────────────┘ └─────────┘  └────────────────┘ 
src  └────────────────────────┘ └─────────┘  └────────────────┘
typ  └────────────────────────┘ └─────────┘  └────────────────┘ 
doc  └────────────────────────┘
1372  
1373  @[nolint] -- see Note [nolint_ge]
doc    └────┘
1374  lemma is_cobounded_under_ge_of_tendsto {f : filter β} {u : β → α} {a : α}
id                                               └────┘                  
src                                              └────┘
typ                                              └────┘                  
1375    (hf : f ≠ ⊥) (h : tendsto u f (𝓝 a)) : f.is_cobounded_under (≥) u :=
id                    └─────┘          └─────────────────┘    
src                    └─────┘              └─────────────────┘ 
typ                   └─────┘          └─────────────────┘    
doc                      └─────┘      
1376  is_cobounded_of_is_bounded (map_ne_bot hf) (is_bounded_under_le_of_tendsto h)
id   └────────────────────────┘  └────────┘ └┘   └────────────────────────────┘ 
src  └────────────────────────┘  └────────┘      └────────────────────────────┘
typ  └────────────────────────┘  └────────┘ └┘   └────────────────────────────┘ 
doc  └────────────────────────┘
1377  
1378  end order_closed_topology
1379  
1380  section order_closed_topology
1381  variables [semilattice_inf α] [topological_space α] [order_topology α]
id              └─────────────┘     └───────────────┘     └────────────┘
src             └─────────────┘     └───────────────┘     └────────────┘
typ             └─────────────┘     └───────────────┘     └────────────┘
doc             └─────────────┘     └───────────────┘     └────────────┘
1382  
1383  @[nolint] -- see Note [nolint_ge]
doc    └────┘
1384  lemma is_bounded_ge_nhds (a : α) : (𝓝 a).is_bounded (≥) :=
id                                        └────────┘  
src                                         └────────┘  
typ                                       └────────┘  
doc                                         └────────┘
1385  match forall_le_or_exists_lt_inf a with
id         └────────────────────────┘ 
src        └────────────────────────┘
typ        └────────────────────────┘ 
1386  | or.inl h := ⟨a, eventually_of_forall _ h⟩
id     └────┘        └──────────────────┘
src    └────┘          └──────────────────┘
typ    └────┘        └──────────────────┘
1387  | or.inr ⟨b, hb⟩ := ⟨b, le_mem_nhds hb⟩
id     └────┘    └┘         └─────────┘
src    └────┘                └─────────┘
typ    └────┘    └┘         └─────────┘
1388  end
1389  
1390  @[nolint] -- see Note [nolint_ge]
doc    └────┘
1391  lemma is_bounded_under_ge_of_tendsto {f : filter β} {u : β → α} {a : α}
id                                             └────┘                  
src                                            └────┘
typ                                            └────┘                  
1392    (h : tendsto u f (𝓝 a)) : f.is_bounded_under (≥) u :=
id          └─────┘          └───────────────┘    
src         └─────┘              └───────────────┘ 
typ         └─────┘          └───────────────┘    
doc         └─────┘      
1393  is_bounded_of_le h (is_bounded_ge_nhds a)
id   └──────────────┘   └────────────────┘ 
src  └──────────────┘    └────────────────┘
typ  └──────────────┘   └────────────────┘ 
1394  
1395  lemma is_cobounded_le_nhds (a : α) : (𝓝 a).is_cobounded (≤) :=
id                                          └──────────┘  
src                                           └──────────┘  
typ                                         └──────────┘  
doc                                           └──────────┘
1396  is_cobounded_of_is_bounded nhds_ne_bot (is_bounded_ge_nhds a)
id   └────────────────────────┘ └─────────┘  └────────────────┘ 
src  └────────────────────────┘ └─────────┘  └────────────────┘
typ  └────────────────────────┘ └─────────┘  └────────────────┘ 
doc  └────────────────────────┘
1397  
1398  lemma is_cobounded_under_le_of_tendsto {f : filter β} {u : β → α} {a : α}
id                                               └────┘                  
src                                              └────┘
typ                                              └────┘                  
1399    (hf : f ≠ ⊥) (h : tendsto u f (𝓝 a)) : f.is_cobounded_under (≤) u :=
id                    └─────┘          └─────────────────┘    
src                    └─────┘              └─────────────────┘ 
typ                   └─────┘          └─────────────────┘    
doc                      └─────┘      
1400  is_cobounded_of_is_bounded (map_ne_bot hf) (is_bounded_under_ge_of_tendsto h)
id   └────────────────────────┘  └────────┘ └┘   └────────────────────────────┘ 
src  └────────────────────────┘  └────────┘      └────────────────────────────┘
typ  └────────────────────────┘  └────────┘ └┘   └────────────────────────────┘ 
doc  └────────────────────────┘
1401  
1402  end order_closed_topology
1403  
1404  section conditionally_complete_linear_order
1405  variables [conditionally_complete_linear_order α]
id              └─────────────────────────────────┘
src             └─────────────────────────────────┘
typ             └─────────────────────────────────┘
1406  
1407  theorem lt_mem_sets_of_Limsup_lt {f : filter α} {b} (h : f.is_bounded (≤)) (l : f.Limsup < b) :
id                                         └────┘            └─────────┘          └─────┘  
src                                        └────┘              └─────────┘           └─────┘ 
typ                                        └────┘            └─────────┘          └─────┘  
doc                                                            └─────────┘
1408    ∀ᶠ a in f, a < b :=
id     └┘  └┘    
src    └┘   └┘     
typ    └┘  └┘    
doc    └┘   └┘  
1409  let ⟨c, (h : ∀ᶠ a in f, a ≤ c), hcb⟩ := exists_lt_of_cInf_lt h l in
id   └─┘         └┘  └┘        └─┘     └──────────────────┘  
src               └┘   └┘                  └──────────────────┘
typ  └─┘         └┘  └┘        └─┘     └──────────────────┘  
doc               └┘   └┘                   └──────────────────┘
1410  mem_sets_of_superset h $ assume a hac, lt_of_le_of_lt hac hcb
id   └──────────────────┘             └─┘  └────────────┘ └─┘
src  └──────────────────┘                   └────────────┘
typ  └──────────────────┘             └─┘  └────────────┘ └─┘
1411  
1412  @[nolint] -- see Note [nolint_ge]
doc    └────┘
1413  theorem gt_mem_sets_of_Liminf_gt : ∀ {f : filter α} {b}, f.is_bounded (≥) → f.Liminf > b →
id                                             └────┘       └─────────┘      └─────┘  
src                                            └────┘          └─────────┘       └─────┘ 
typ                                            └────┘       └─────────┘      └─────┘  
doc                                                            └─────────┘
1414    ∀ᶠ a in f, a > b :=
id     └┘  └┘    
src    └┘   └┘     
typ    └┘  └┘    
doc    └┘   └┘  
1415  @lt_mem_sets_of_Limsup_lt (order_dual α) _
id    └──────────────────────┘  └────────┘ 
src   └──────────────────────┘  └────────┘
typ   └──────────────────────┘  └────────┘ 
doc                             └────────┘
1416  
1417  variables [topological_space α] [order_topology α]
id              └───────────────┘     └────────────┘
src             └───────────────┘     └────────────┘
typ             └───────────────┘     └────────────┘
doc             └───────────────┘     └────────────┘
1418  
1419  /-- If the liminf and the limsup of a filter coincide, then this filter converges to
1420  their common value, at least if the filter is eventually bounded above and below. -/
1421  @[nolint] -- see Note [nolint_ge]
doc    └────┘
1422  theorem le_nhds_of_Limsup_eq_Liminf {f : filter α} {a : α}
id                                            └────┘        
src                                           └────┘
typ                                           └────┘        
1423    (hl : f.is_bounded (≤)) (hg : f.is_bounded (≥)) (hs : f.Limsup = a) (hi : f.Liminf = a) :
id           └─────────┘           └─────────┘           └─────┘          └─────┘  
src           └─────────┘            └─────────┘            └─────┘            └─────┘ 
typ          └─────────┘           └─────────┘           └─────┘          └─────┘  
doc           └─────────┘             └─────────┘
1424    f ≤ 𝓝 a :=
id        
src       
typ       
doc        
1425  tendsto_order.2 $ and.intro
id   └───────────┘    └───────┘
src  └───────────┘    └───────┘
typ  └───────────┘    └───────┘
1426    (assume b hb, gt_mem_sets_of_Liminf_gt hg $ hi.symm ▸ hb)
id              └┘  └──────────────────────┘ └┘   └┘└───┘  └┘
src                  └──────────────────────┘        └───┘ 
typ             └┘  └──────────────────────┘ └┘   └┘└───┘  └┘
1427    (assume b hb, lt_mem_sets_of_Limsup_lt hl $ hs.symm ▸ hb)
id              └┘  └──────────────────────┘ └┘   └┘└───┘  └┘
src                  └──────────────────────┘        └───┘ 
typ             └┘  └──────────────────────┘ └┘   └┘└───┘  └┘
1428  
1429  theorem Limsup_nhds (a : α) : Limsup (𝓝 a) = a :=
id                                └────┘      
src                                └────┘      
typ                               └────┘      
doc                                        
1430  cInf_intro (is_bounded_le_nhds a)
id   └────────┘  └────────────────┘ 
src  └────────┘  └────────────────┘
typ  └────────┘  └────────────────┘ 
doc  └────────┘
1431    (assume a' (h : {n : α | n ≤ a'} ∈ 𝓝 a), show a ≤ a', from @mem_of_nhds α _ a _ h)
id             └┘               └┘              └┘        └─────────┘       
src                                                           └─────────┘
typ            └┘               └┘              └┘        └─────────┘       
doc                                       
1432    (assume b (hba : a < b), show ∃c (h : {n : α | n ≤ c} ∈ 𝓝 a), c < b, from
id                                                      
src                                                             
typ                                                     
doc                                                            
1433      match dense_or_discrete a b with
id             └───────────────┘  
src            └───────────────┘
typ            └───────────────┘  
1434      | or.inl ⟨c, hac, hcb⟩ := ⟨c, ge_mem_nhds hac, hcb⟩
id         └────┘    └─┘  └─┘         └─────────┘
src        └────┘                      └─────────┘
typ        └────┘    └─┘  └─┘         └─────────┘
1435      | or.inr ⟨_, h⟩        := ⟨a, (𝓝 a).sets_of_superset (gt_mem_nhds hba) h, hba⟩
id         └────┘                       └──────────────┘   └─────────┘ └─┘     └─┘
src        └────┘                          └──────────────┘   └─────────┘
typ        └────┘                       └──────────────┘   └─────────┘ └─┘     └─┘
doc                                     
1436      end)
1437  
1438  theorem Liminf_nhds : ∀ (a : α), Liminf (𝓝 a) = a :=
id                                   └────┘      
src                                   └────┘      
typ                                  └────┘      
doc                                           
1439  @Limsup_nhds (order_dual α) _ _ _
id    └─────────┘  └────────┘ 
src   └─────────┘  └────────┘
typ   └─────────┘  └────────┘ 
doc                └────────┘
1440  
1441  /-- If a filter is converging, its limsup coincides with its limit. -/
1442  theorem Liminf_eq_of_le_nhds {f : filter α} {a : α} (hf : f ≠ ⊥) (h : f ≤ 𝓝 a) : f.Liminf = a :=
id                                     └────┘                                └─────┘  
src                                    └────┘                                      └─────┘ 
typ                                    └────┘                                └─────┘  
doc                                                                            
1443  have hb_ge : is_bounded (≥) f, from is_bounded_of_le h (is_bounded_ge_nhds a),
id                └────────┘           └──────────────┘   └────────────────┘ 
src               └────────┘            └──────────────┘    └────────────────┘
typ               └────────┘           └──────────────┘   └────────────────┘ 
doc               └────────┘
1444  have hb_le : is_bounded (≤) f, from is_bounded_of_le h (is_bounded_le_nhds a),
id                └────────┘           └──────────────┘   └────────────────┘ 
src               └────────┘            └──────────────┘    └────────────────┘
typ               └────────┘           └──────────────┘   └────────────────┘ 
doc               └────────┘
1445  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
1446    (calc f.Liminf ≤ f.Limsup : Liminf_le_Limsup hf hb_le hb_ge
id           └─────┘   └─────┘   └──────────────┘ └┘ └───┘ └───┘
src           └─────┘    └─────┘   └──────────────┘
typ          └─────┘   └─────┘   └──────────────┘ └┘ └───┘ └───┘
1447      ... ≤ (𝓝 a).Limsup :
id                └────┘
src                └────┘
typ               └────┘
doc             
1448        Limsup_le_Limsup_of_le h (is_cobounded_of_is_bounded hf hb_ge) (is_bounded_le_nhds a)
id         └────────────────────┘   └────────────────────────┘ └┘ └───┘   └────────────────┘ 
src        └────────────────────┘    └────────────────────────┘            └────────────────┘
typ        └────────────────────┘   └────────────────────────┘ └┘ └───┘   └────────────────┘ 
doc                                  └────────────────────────┘
1449      ... = a : Limsup_nhds a)
id                └─────────┘ 
src                └─────────┘
typ               └─────────┘ 
1450    (calc a = (𝓝 a).Liminf : (Liminf_nhds a).symm
id                 └────┘     └─────────┘  └──┘
src                  └────┘     └─────────┘   └──┘
typ                └────┘     └─────────┘  └──┘
doc               
1451      ... ≤ f.Liminf :
id             └─────┘
src             └─────┘
typ            └─────┘
1452        Liminf_le_Liminf_of_le h (is_bounded_ge_nhds a) (is_cobounded_of_is_bounded hf hb_le))
id         └────────────────────┘   └────────────────┘    └────────────────────────┘ └┘ └───┘
src        └────────────────────┘    └────────────────┘     └────────────────────────┘
typ        └────────────────────┘   └────────────────┘    └────────────────────────┘ └┘ └───┘
doc                                                         └────────────────────────┘
1453  
1454  /-- If a filter is converging, its liminf coincides with its limit. -/
1455  theorem Limsup_eq_of_le_nhds : ∀ {f : filter α} {a : α}, f ≠ ⊥ → f ≤ 𝓝 a → f.Limsup = a :=
id                                         └────┘                      └─────┘  
src                                        └────┘                            └─────┘ 
typ                                        └────┘                      └─────┘  
doc                                                                       
1456  @Liminf_eq_of_le_nhds (order_dual α) _ _ _
id    └──────────────────┘  └────────┘ 
src   └──────────────────┘  └────────┘
typ   └──────────────────┘  └────────┘ 
doc   └──────────────────┘  └────────┘
1457  
1458  end conditionally_complete_linear_order
1459  
1460  section complete_linear_order
1461  variables [complete_linear_order α] [topological_space α] [order_topology α]
id              └───────────────────┘     └───────────────┘     └────────────┘
src             └───────────────────┘     └───────────────┘     └────────────┘
typ             └───────────────────┘     └───────────────┘     └────────────┘
doc             └───────────────────┘     └───────────────┘     └────────────┘
1462  -- In complete_linear_order, the above theorems take a simpler form
1463  
1464  /-- If the liminf and the limsup of a function coincide, then the limit of the function
1465  exists and has the same value -/
1466  theorem tendsto_of_liminf_eq_limsup {f : filter β} {u : β → α} {a : α}
id                                            └────┘                  
src                                           └────┘
typ                                           └────┘                  
1467    (h : liminf f u = a ∧ limsup f u = a) : tendsto u f (𝓝 a) :=
id          └────┘      └────┘        └─────┘     
src         └────┘         └────┘           └─────┘      
typ         └────┘      └────┘        └─────┘     
doc                                            └─────┘      
1468    le_nhds_of_Limsup_eq_Liminf is_bounded_le_of_top is_bounded_ge_of_bot h.2 h.1
id     └─────────────────────────┘ └──────────────────┘ └──────────────────┘   
src    └─────────────────────────┘ └──────────────────┘ └──────────────────┘     
typ    └─────────────────────────┘ └──────────────────┘ └──────────────────┘   
doc    └─────────────────────────┘
1469  
1470  /-- If a function has a limit, then its limsup coincides with its limit-/
1471  theorem limsup_eq_of_tendsto {f : filter β} {u : β → α} {a : α} (hf : f ≠ ⊥)
id                                     └────┘                            
src                                    └────┘                                 
typ                                    └────┘                            
1472    (h : tendsto u f (𝓝 a)) : limsup f u = a :=
id          └─────┘          └────┘    
src         └─────┘             └────┘     
typ         └─────┘          └────┘    
doc         └─────┘      
1473    Limsup_eq_of_le_nhds (map_ne_bot hf) h
id     └──────────────────┘  └────────┘ └┘  
src    └──────────────────┘  └────────┘
typ    └──────────────────┘  └────────┘ └┘  
doc    └──────────────────┘
1474  
1475  /-- If a function has a limit, then its liminf coincides with its limit-/
1476  theorem liminf_eq_of_tendsto {f : filter β} {u : β → α} {a : α} (hf : f ≠ ⊥)
id                                     └────┘                            
src                                    └────┘                                 
typ                                    └────┘                            
1477    (h : tendsto u f (𝓝 a)) : liminf f u = a :=
id          └─────┘          └────┘    
src         └─────┘             └────┘     
typ         └─────┘          └────┘    
doc         └─────┘      
1478    Liminf_eq_of_le_nhds (map_ne_bot hf) h
id     └──────────────────┘  └────────┘ └┘  
src    └──────────────────┘  └────────┘
typ    └──────────────────┘  └────────┘ └┘  
doc    └──────────────────┘
1479  
1480  end complete_linear_order
1481  
1482  end liminf_limsup
1483  
1484  end order_topology
1485  
1486  @[nolint] -- see Note [nolint_ge]
doc    └────┘
1487  lemma order_topology_of_nhds_abs
1488    {α : Type*} [decidable_linear_ordered_comm_group α] [topological_space α]
id                  └─────────────────────────────────┘    └───────────────┘ 
src                 └─────────────────────────────────┘     └───────────────┘
typ                 └─────────────────────────────────┘    └───────────────┘ 
doc                                                         └───────────────┘
1489    (h_nhds : ∀a:α, 𝓝 a = (⨅r>0, principal {b | abs (a - b) < r})) : order_topology α :=
id                           └───────┘    └─┘             └────────────┘ 
src                             └───────┘     └─┘                └────────────┘
typ                          └───────┘    └─┘             └────────────┘ 
doc                              └───────┘                           └────────────┘
1490  order_topology.mk $ eq_of_nhds_eq_nhds $ assume a:α, le_antisymm_iff.mpr
id   └───────────────┘   └────────────────┘              └─────────────┘└──┘
src  └───────────────┘   └────────────────┘               └─────────────┘└──┘
typ  └───────────────┘   └────────────────┘              └─────────────┘└──┘
1491  begin
st   └─────
1492    simp [infi_and, topological_space.nhds_generate_from,
id           └──────┘  └──────────────────────────────────┘
src    └────┘└──────┘└┘└──────────────────────────────────┘└─
typ    └────┘└──────┘└┘└──────────────────────────────────┘└─
doc    └────┘        └┘                                    └─
txt    └────┘        └┘                                    └─
par    └────┘        └┘                                    └─
pid                └┘                                    └─
st   ────────────────────────────────────────────────────────
1493          h_nhds, le_infi_iff, -le_principal_iff, and_comm],
id           └────┘  └─────────┘                     └──────┘
src  ───────┘      └┘└─────────┘└───────────────────┘└──────┘
typ  ───────┘└────┘└┘└─────────┘└───────────────────┘└──────┘
doc  ───────┘      └┘           └───────────────────┘        
txt  ───────┘      └┘           └───────────────────┘        
par  ───────┘      └┘           └───────────────────┘        
pid  ───────┘      └┘           └───────────────────┘        
st   ────────────────────────────────────────────────────────┘└─
1494    refine ⟨λ s ha b hs, _, λ r hr, _⟩,
src    └─────┘  └─────────────┘ └───────┘
typ    └─────┘  └─────────────┘ └───────┘
doc    └─────┘  └─────────────┘ └───────┘
txt    └─────┘  └─────────────┘ └───────┘
par    └─────┘  └─────────────┘ └───────┘
pid            └─────────────┘ └───────┘
st   ───────────────────────────────────┘└─
1495    { rcases hs with rfl | rfl,
id              └┘
src      └─────┘  └─────────────┘
typ      └─────┘└┘└─────────────┘
doc      └─────┘  └─────────────┘
txt      └─────┘  └─────────────┘
par      └─────┘  └─────────────┘
pid              └─────────────┘
st   ───┘└──────────────────────┘└─
1496      { refine infi_le_of_le (a - b)
id                                 
src        └─────┘                └─
typ        └─────┘                └─
doc        └─────┘                 └─
txt        └─────┘                 └─
par        └─────┘                 └─
pid                               └─
st   ─────┘└────────────────────────────
1497          (infi_le_of_le (lt_sub_left_of_add_lt $ by simpa using ha) $
id            └───────────┘  └───────────────────┘                  └┘
src  ───────┘ └───────────┘ └───────────────────┘   └──────────┘  └┘ 
typ  ───────┘ └───────────┘ └───────────────────┘   └──────────┘└┘└┘ 
doc  ───────┘                                       └──────────┘  └┘ 
txt  ───────┘                                       └──────────┘  └┘ 
par  ───────┘                                       └──────────┘  └┘ 
pid  ───────┘                                       └───────────┘  └┘ 
st   ─────────────────────────────────────────────────┘└─────────────┘└───
1498            principal_mono.mpr $ assume c (hc : abs (a - c) < a - b), _),
id             └────────────────┘                  └─┘             
src  ─────────┘└────────────────┘       └───────┘└─┘    └┘   └───┘
typ  ─────────┘└────────────────┘       └───────┘└─┘    └┘ └───┘
doc  ─────────┘                         └───────┘       └┘    └───┘
txt  ─────────┘                         └───────┘       └┘    └───┘
par  ─────────┘                         └───────┘       └┘    └───┘
pid  ─────────┘                         └───────┘       └┘    └───┘
st   ─────────────────────────────────────────────────────────────────────┘└─
1499        have : a - c < a - b := lt_of_le_of_lt (le_abs_self _) hc,
id                              └────────────┘  └─────────┘    └┘
src        └─────┘       └──┘└────────────┘ └─────────┘└──┘
typ        └─────┘    └──┘└────────────┘ └─────────┘└──┘└┘
doc        └─────┘       └──┘                          └──┘
txt        └─────┘       └──┘                          └──┘
par        └─────┘       └──┘                          └──┘
pid        └───┘└┘       └──┘                          └──┘
st   ──────────────────────────────────────────────────────────────┘└─
1500        exact lt_of_neg_lt_neg (lt_of_add_lt_add_left this) },
id               └──────────────┘  └───────────────────┘ └──┘
src        └────┘└──────────────┘ └───────────────────┘    └┘
typ        └────┘└──────────────┘ └───────────────────┘└──┘└┘
doc        └────┘                                          └┘
txt        └────┘                                          └┘
par        └────┘                                          └┘
pid                                                       
st   ─────────────────────────────────────────────────────────┘└┘
1501      { refine infi_le_of_le (b - a)
src        └─────┘                 └─
typ        └─────┘                 └─
doc        └─────┘                 └─
txt        └─────┘                 └─
par        └─────┘                 └─
pid                               └─
st   ───────────────────────────────────
1502          (infi_le_of_le (lt_sub_left_of_add_lt $ by simpa using ha) $
id            └───────────┘  └───────────────────┘                  └┘
src  ───────┘ └───────────┘ └───────────────────┘   └──────────┘  └┘ 
typ  ───────┘ └───────────┘ └───────────────────┘   └──────────┘└┘└┘ 
doc  ───────┘                                       └──────────┘  └┘ 
txt  ───────┘                                       └──────────┘  └┘ 
par  ───────┘                                       └──────────┘  └┘ 
pid  ───────┘                                       └───────────┘  └┘ 
st   ─────────────────────────────────────────────────┘└─────────────┘└───
1503            principal_mono.mpr $ assume c (hc : abs (a - c) < b - a), _),
id             └────────────────┘                  └─┘             
src  ─────────┘└────────────────┘       └───────┘└─┘    └┘    └───┘
typ  ─────────┘└────────────────┘       └───────┘└─┘    └┘ └───┘
doc  ─────────┘                         └───────┘       └┘    └───┘
txt  ─────────┘                         └───────┘       └┘    └───┘
par  ─────────┘                         └───────┘       └┘    └───┘
pid  ─────────┘                         └───────┘       └┘    └───┘
st   ─────────────────────────────────────────────────────────────────────┘└─
1504        have : abs (c - a) < b - a, {rw abs_sub; simpa using hc},
id                └─┘                   └─────┘              └┘
src        └─────┘└─┘    └┘       └─┘└─────┘  └──────────┘
typ        └─────┘└─┘   └┘     └─┘└─────┘  └──────────┘└┘
doc        └─────┘       └┘       └─┘         └──────────┘
txt        └─────┘       └┘       └─┘         └──────────┘
par        └─────┘       └┘       └─┘         └──────────┘
pid        └───┘└┘       └┘                       └────┘
st   ───────────────────────────────┘└────┘└─────┘└──────────────┘└┘
1505        have : c - a < b - a := lt_of_le_of_lt (le_abs_self _) this,
id                              └────────────┘  └─────────┘    └──┘
src        └─────┘       └──┘└────────────┘ └─────────┘└──┘
typ        └─────┘    └──┘└────────────┘ └─────────┘└──┘└──┘
doc        └─────┘       └──┘                          └──┘
txt        └─────┘       └──┘                          └──┘
par        └─────┘       └──┘                          └──┘
pid        └───┘└┘       └──┘                          └──┘
st   ────────────────────────────────────────────────────────────────┘└─
1506        exact lt_of_add_lt_add_right this } },
id               └────────────────────┘ └──┘
src        └────┘└────────────────────┘    
typ        └────┘└────────────────────┘└──┘
doc        └────┘                          
txt        └────┘                          
par        └────┘                          
pid                                       
st   ───────────────────────────────────────┘└──┘
1507    { have h : {b | abs (a + -b) < r} = {b | a - r < b} ∩ {b | b < a + r},
id                     └─┘                                          
src      └───────┘ └──┘└─┘   └┘  └┘ └──┘     └┘└──┘     
typ      └───────┘ └──┘└─┘   └┘  └┘ └──┘     └┘└──┘   
doc      └───────┘ └──┘        └┘  └┘  └──┘     └┘  └──┘     
txt      └───────┘ └──┘        └┘  └┘  └──┘     └┘  └──┘     
par      └───────┘ └──┘        └┘  └┘  └──┘     └┘  └──┘     
pid      └────┘└─┘ └──┘        └┘  └┘  └──┘     └┘  └──┘     
st   ──────────────────────────────────────────────────────────────────────┘└─
1508        from set.ext (assume b,
id              └─────┘
src        └───┘└─────┘       └───
typ        └───┘└─────┘       └───
doc        └───┘              └───
txt        └───┘              └───
par        └───┘              └───
pid        └───┘              └───
st   ──────────────────────────────
1509          by simp [abs_lt, -sub_eq_add_neg, (sub_eq_add_neg _ _).symm,
id                    └────┘                    └────────────┘
src  ───────┘  └────┘└────┘└─────────────────┘ └────────────┘└───────────
typ  ───────┘  └────┘└────┘└─────────────────┘ └────────────┘└───────────
doc  ───────┘  └────┘      └─────────────────┘               └───────────
txt  ───────┘  └────┘      └─────────────────┘               └───────────
par  ───────┘  └────┘      └─────────────────┘               └───────────
pid  ───────┘  └─────┘      └─────────────────┘               └───────────
st   ─────────┘└──────────────────────────────────────────────────────────
1510            sub_lt, lt_sub_iff_add_lt, and_comm, sub_lt_iff_lt_add']),
id             └────┘  └───────────────┘  └──────┘  └────────────────┘
src  ─────────┘└────┘└┘└───────────────┘└┘└──────┘└┘└────────────────┘
typ  ─────────┘└────┘└┘└───────────────┘└┘└──────┘└┘└────────────────┘
doc  ─────────┘      └┘                 └┘        └┘                  
txt  ─────────┘      └┘                 └┘        └┘                  
par  ─────────┘      └┘                 └┘        └┘                  
pid  ─────────┘      └┘                 └┘        └┘                  └┘
st   ─────────────────────────────────────────────────────────────────┘└─
1511      rw [h, ← inf_principal],
id               └───────────┘
src      └──┘ └──┘└───────────┘
typ      └──┘└──┘└───────────┘
doc      └──┘ └──┘             
txt      └──┘ └──┘             
par      └──┘ └──┘             
pid        └┘ └──┘             
st   ────────┘└───────────────┘└──
1512      apply le_inf _ _,
id             └────┘
src      └────┘└────┘└──┘
typ      └────┘└────┘└──┘
doc      └────┘      └──┘
txt      └────┘      └──┘
par      └────┘      └──┘
pid                 └──┘
st   ───────────────────┘└─
1513      { exact infi_le_of_le {b : α | a - r < b} (infi_le_of_le (sub_lt_self a hr) $
id                                                                └─────────┘   └┘
src        └────┘              └──┘ └─┘     └┘               └─────────┘   └┘ 
typ        └────┘              └──┘└─┘     └┘               └─────────┘ └┘└┘ 
doc        └────┘              └──┘ └─┘     └┘                             └┘ 
txt        └────┘              └──┘ └─┘     └┘                             └┘ 
par        └────┘              └──┘ └─┘     └┘                             └┘ 
pid                           └──┘ └─┘     └┘                             └┘ 
st   ─────┘└───────────────────────────────────────────────────────────────────────────
1514          infi_le_of_le (a - r) $ infi_le _ (or.inl rfl)) },
id           └───────────┘         └─────┘    └────┘ └─┘
src  ───────┘└───────────┘    └┘ └─────┘└─┘ └────┘└─┘└─┘
typ  ───────┘└───────────┘  └┘ └─────┘└─┘ └────┘└─┘└─┘
doc  ───────┘                 └┘        └─┘          └─┘
txt  ───────┘                 └┘        └─┘          └─┘
par  ───────┘                 └┘        └─┘          └─┘
pid  ───────┘                 └┘        └─┘          └┘
st   ───────────────────────────────────────────────────────┘└┘
1515      { exact infi_le_of_le {b : α | b < a + r} (infi_le_of_le (lt_add_of_pos_right _ hr) $
id                                                                └─────────────────┘   └┘
src        └────┘              └──┘ └─┘     └┘               └─────────────────┘└─┘  └┘ 
typ        └────┘              └──┘└─┘     └┘               └─────────────────┘└─┘└┘└┘ 
doc        └────┘              └──┘ └─┘     └┘                                  └─┘  └┘ 
txt        └────┘              └──┘ └─┘     └┘                                  └─┘  └┘ 
par        └────┘              └──┘ └─┘     └┘                                  └─┘  └┘ 
pid                           └──┘ └─┘     └┘                                  └─┘  └┘ 
st   ──────────────────────────────────────────────────────────────────────────────────────────
1516          infi_le_of_le (a + r) $ infi_le _ (or.inr rfl)) } }
id           └───────────┘         └─────┘    └────┘ └─┘
src  ───────┘└───────────┘    └┘ └─────┘└─┘ └────┘└─┘└─┘
typ  ───────┘└───────────┘  └┘ └─────┘└─┘ └────┘└─┘└─┘
doc  ───────┘                 └┘        └─┘          └─┘
txt  ───────┘                 └┘        └─┘          └─┘
par  ───────┘                 └┘        └─┘          └─┘
pid  ───────┘                 └┘        └─┘          └┘
st   ───────────────────────────────────────────────────────┘└───
1517  end
st   ──┘
1518  
1519  lemma tendsto_at_top_supr_nat [topological_space α] [complete_linear_order α] [order_topology α]
id                                  └───────────────┘    └───────────────────┘    └────────────┘ 
src                                 └───────────────┘     └───────────────────┘     └────────────┘
typ                                 └───────────────┘    └───────────────────┘    └────────────┘ 
doc                                 └───────────────┘     └───────────────────┘     └────────────┘
1520    (f : ℕ → α) (hf : monotone f) : tendsto f at_top (𝓝 (⨆i, f i)) :=
id                     └──────┘     └─────┘  └────┘      
src                     └──────┘      └─────┘   └────┘     
typ                    └──────┘     └─────┘  └────┘      
doc                      └──────┘      └─────┘   └────┘     
1521  tendsto_order.2 $ and.intro
id   └───────────┘    └───────┘
src  └───────────┘    └───────┘
typ  └───────────┘    └───────┘
1522    (assume a ha, let ⟨n, hn⟩ := lt_supr_iff.1 ha in
id              └┘  └─┘    └┘     └─────────┘  └┘
src                                 └─────────┘
typ             └┘  └─┘    └┘     └─────────┘  └┘
1523      mem_at_top_sets.2 ⟨n, assume i hi, lt_of_lt_of_le hn (hf hi)⟩)
id       └─────────────┘              └┘  └────────────┘     └┘ └┘
src      └─────────────┘                   └────────────┘
typ      └─────────────┘              └┘  └────────────┘     └┘ └┘
1524    (assume a ha, univ_mem_sets' (assume n, lt_of_le_of_lt (le_supr _ n) ha))
id              └┘  └────────────┘           └────────────┘  └─────┘     └┘
src                  └────────────┘            └────────────┘  └─────┘
typ             └┘  └────────────┘           └────────────┘  └─────┘     └┘
1525  
1526  lemma tendsto_at_top_infi_nat [topological_space α] [complete_linear_order α] [order_topology α]
id                                  └───────────────┘    └───────────────────┘    └────────────┘ 
src                                 └───────────────┘     └───────────────────┘     └────────────┘
typ                                 └───────────────┘    └───────────────────┘    └────────────┘ 
doc                                 └───────────────┘     └───────────────────┘     └────────────┘
1527    (f : ℕ → α) (hf : ∀{n m}, n ≤ m → f m ≤ f n) : tendsto f at_top (𝓝 (⨅i, f i)) :=
id                                        └─────┘  └────┘      
src                                                └─────┘   └────┘     
typ                                       └─────┘  └────┘      
doc                                                   └─────┘   └────┘     
1528  @tendsto_at_top_supr_nat (order_dual α) _ _ _ _ @hf
id    └─────────────────────┘  └────────┘            └┘
src   └─────────────────────┘  └────────┘
typ   └─────────────────────┘  └────────┘            └┘
doc                            └────────┘
1529  
1530  lemma supr_eq_of_tendsto {α} [topological_space α] [complete_linear_order α] [order_topology α]
id                                 └───────────────┘    └───────────────────┘    └────────────┘ 
src                                └───────────────┘     └───────────────────┘     └────────────┘
typ                                └───────────────┘    └───────────────────┘    └────────────┘ 
doc                                └───────────────┘     └───────────────────┘     └────────────┘
1531    {f : ℕ → α} {a : α} (hf : monotone f) : tendsto f at_top (𝓝 a) → supr f = a :=
id                            └──────┘     └─────┘  └────┘       └──┘   
src                             └──────┘      └─────┘   └────┘        └──┘   
typ                           └──────┘     └─────┘  └────┘       └──┘   
doc                              └──────┘      └─────┘   └────┘        └──┘
1532  tendsto_nhds_unique at_top_ne_bot (tendsto_at_top_supr_nat f hf)
id   └─────────────────┘ └───────────┘  └─────────────────────┘  └┘
src  └─────────────────┘ └───────────┘  └─────────────────────┘
typ  └─────────────────┘ └───────────┘  └─────────────────────┘  └┘
1533  
1534  lemma infi_eq_of_tendsto {α} [topological_space α] [complete_linear_order α] [order_topology α]
id                                 └───────────────┘    └───────────────────┘    └────────────┘ 
src                                └───────────────┘     └───────────────────┘     └────────────┘
typ                                └───────────────┘    └───────────────────┘    └────────────┘ 
doc                                └───────────────┘     └───────────────────┘     └────────────┘
1535    {f : ℕ → α} {a : α} (hf : ∀n m, n ≤ m → f m ≤ f n) : tendsto f at_top (𝓝 a) → infi f = a :=
id                                             └─────┘  └────┘       └──┘   
src                                                      └─────┘   └────┘        └──┘   
typ                                            └─────┘  └────┘       └──┘   
doc                                                         └─────┘   └────┘        └──┘
1536  tendsto_nhds_unique at_top_ne_bot (tendsto_at_top_infi_nat f hf)
id   └─────────────────┘ └───────────┘  └─────────────────────┘  └┘
src  └─────────────────┘ └───────────┘  └─────────────────────┘
typ  └─────────────────┘ └───────────┘  └─────────────────────┘  └┘
1537  
1538  lemma tendsto_abs_at_top_at_top [decidable_linear_ordered_comm_group α] : tendsto (abs : α → α) at_top at_top :=
id                                    └─────────────────────────────────┘     └─────┘  └─┘        └────┘ └────┘
src                                   └─────────────────────────────────┘      └─────┘  └─┘          └────┘ └────┘
typ                                   └─────────────────────────────────┘     └─────┘  └─┘        └────┘ └────┘
doc                                                                            └─────┘               └────┘ └────┘
1539  tendsto_at_top_mono _ (λ n, le_abs_self _) tendsto_id
id   └─────────────────┘        └─────────┘    └────────┘
src  └─────────────────┘         └─────────┘    └────────┘
typ  └─────────────────┘        └─────────┘    └────────┘
1540  
1541  local notation `|` x `|` := abs x
id                               └─┘
src                              └─┘
typ                              └─┘
1542  
1543  @[nolint] -- see Note [nolint_ge]
doc    └────┘
1544  lemma decidable_linear_ordered_comm_group.tendsto_nhds
1545    [decidable_linear_ordered_comm_group α] [topological_space α] [order_topology α] {β : Type*}
id      └─────────────────────────────────┘    └───────────────┘    └────────────┘ 
src     └─────────────────────────────────┘     └───────────────┘     └────────────┘
typ     └─────────────────────────────────┘    └───────────────┘    └────────────┘ 
doc                                             └───────────────┘     └────────────┘
1546    (f : β → α) (x : filter β) (a : α) :
id                    └────┘        
src                     └────┘
typ                   └────┘        
1547    filter.tendsto f x (nhds a) ↔ ∀ ε > (0 : α), ∀ᶠ b in x, |f b - a| < ε :=
id     └────────────┘    └──┘                 └┘  └┘       
src    └────────────┘      └──┘                    └┘   └┘          
typ    └────────────┘    └──┘                 └┘  └┘       
doc    └────────────┘      └──┘                     └┘   └┘  
1548  begin
st   └─────
1549    rw (show _, from @tendsto_order α), -- does not work without `show` for some reason
id                       └───────────┘ 
src    └─┘     └───────┘ └───────────┘ 
typ    └─┘     └───────┘ └───────────┘
doc    └─┘     └───────┘               
txt    └─┘     └───────┘               
par    └─┘     └───────┘               
pid           └───────┘               
st   ───────────────────────────────────┘└─────────────────────────────────────────────────
1550    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
1551    { rintros ⟨hyp_lt_a, hyp_gt_a⟩ ε ε_pos,
src      └──────────────────────────────────┘
typ      └──────────────────────────────────┘
doc      └──────────────────────────────────┘
txt      └──────────────────────────────────┘
par      └──────────────────────────────────┘
pid             └───────────────────────────┘
st   ───┘└──────────────────────────────────┘└─
1552      suffices : {b : β | f b - a < ε ∧ a - f b < ε} ∈ x, by simpa only [abs_sub_lt_iff],
id                                                                 └────────────┘
src      └─────────┘└──┘ └─┘           └┘      └──────────┘└────────────┘
typ      └─────────┘└──┘└─┘        └┘     └──────────┘└────────────┘
doc      └─────────┘ └──┘ └─┘             └┘       └──────────┘              
txt      └─────────┘ └──┘ └─┘             └┘       └──────────┘              
par      └─────────┘ └──┘ └─┘             └┘       └──────────┘              
pid      └───────┘└┘ └──┘ └─┘             └┘            └──┘└┘              
st   ─────────────────────────────────────────────────────┘                                └─
1553      have set1 : {b : β | a - f b < ε} ∈ x,
id                                      
src      └──────────┘└──┘ └─┘      └┘ 
typ      └──────────┘└──┘└─┘   └┘ 
doc      └──────────┘ └──┘ └─┘      └┘ 
txt      └──────────┘ └──┘ └─┘      └┘ 
par      └──────────┘ └──┘ └─┘      └┘ 
pid      └───────┘└─┘ └──┘ └─┘      └┘ 
st   ────────────────────────────────────────┘└─
1554      { have : {b : β | a - ε < f b} ∈ x, from hyp_lt_a (a - ε) (sub_lt_self a ε_pos),
id                                          └──────┘         └─────────┘  └───┘
src        └─────┘└──┘ └─┘      └┘    └───┘            └┘ └─────────┘      
typ        └─────┘└──┘└─┘   └┘   └───┘└──────┘   └┘ └─────────┘└───┘
doc        └─────┘ └──┘ └─┘      └┘    └───┘            └┘                  
txt        └─────┘ └──┘ └─┘      └┘    └───┘            └┘                  
par        └─────┘ └──┘ └─┘      └┘    └───┘            └┘                  
pid        └───┘└┘ └──┘ └─┘      └┘    └───┘            └┘                  
st   ─────┘└──────────────────────────────┘└───────────────────────────────────────────┘└─
1555        have : ∀ b, a - f b < ε ↔ a - ε < f b, by { intro _, exact sub_lt },
id                                                                 └────┘
src        └─────┘ └┘                     └─────┘  └────┘└────┘
typ        └─────┘ └┘                  └─────┘  └────┘└────┘
doc        └─────┘ └┘                     └─────┘  └────┘      
txt        └─────┘ └┘                     └─────┘  └────┘      
par        └─────┘ └┘                     └─────┘  └────┘      
pid        └───┘└┘ └┘                          └┘             
st   ──────────────────────────────────────────┘     └──────┘└─────────────┘└┘
1556        simpa only [this] },
id                     └──┘
src        └──────────┘    └┘
typ        └──────────┘└──┘└┘
doc        └──────────┘    └┘
txt        └──────────┘    └┘
par        └──────────┘    └┘
pid             └──┘└┘    
st   ───────────────────────┘└┘
1557      have set2 : {b : β | f b - a < ε} ∈ x,
id                                      
src      └──────────┘└──┘ └─┘      └┘ 
typ      └──────────┘└──┘└─┘   └┘ 
doc      └──────────┘ └──┘ └─┘      └┘ 
txt      └──────────┘ └──┘ └─┘      └┘ 
par      └──────────┘ └──┘ └─┘      └┘ 
pid      └───────┘└─┘ └──┘ └─┘      └┘ 
st   ────────────────────────────────────────┘└─
1558      { have : {b : β | a + ε > f b} ∈ x, from hyp_gt_a (a + ε) (lt_add_of_pos_right a ε_pos),
id                                        └──────┘         └─────────────────┘  └───┘
src        └─────┘└──┘ └─┘    └┘    └───┘            └┘ └─────────────────┘      
typ        └─────┘└──┘└─┘ └┘   └───┘└──────┘   └┘ └─────────────────┘└───┘
doc        └─────┘ └──┘ └─┘      └┘    └───┘            └┘                          
txt        └─────┘ └──┘ └─┘      └┘    └───┘            └┘                          
par        └─────┘ └──┘ └─┘      └┘    └───┘            └┘                          
pid        └───┘└┘ └──┘ └─┘      └┘    └───┘            └┘                          
st   ─────┘└──────────────────────────────┘└───────────────────────────────────────────────────┘└─
1559        have : ∀ b, f b - a < ε ↔ a + ε > f b, by { intro _, exact sub_lt_iff_lt_add' },
id                                                                 └────────────────┘
src        └─────┘ └┘                     └─────┘  └────┘└────────────────┘
typ        └─────┘ └┘                  └─────┘  └────┘└────────────────┘
doc        └─────┘ └┘                     └─────┘  └────┘                  
txt        └─────┘ └┘                     └─────┘  └────┘                  
par        └─────┘ └┘                     └─────┘  └────┘                  
pid        └───┘└┘ └┘                          └┘                         
st   ──────────────────────────────────────────┘     └──────┘└─────────────────────────┘└┘
1560        simpa only [this] },
id                     └──┘
src        └──────────┘    └┘
typ        └──────────┘└──┘└┘
doc        └──────────┘    └┘
txt        └──────────┘    └┘
par        └──────────┘    └┘
pid             └──┘└┘    
st   ───────────────────────┘└┘
1561      exact (x.inter_sets set2 set1) },
id              └──────────┘ └──┘ └──┘
src      └────┘ └──────────┘        └┘
typ      └────┘ └──────────┘└──┘└──┘└┘
doc      └────┘                     └┘
txt      └────┘                     └┘
par      └────┘                     └┘
pid                                
st   ──────────────────────────────────┘└┘
1562    { assume hyp_ε_pos,
src      └──────────────┘
typ      └──────────────┘
doc      └──────────────┘
txt      └──────────────┘
par      └──────────────┘
pid      └──────────────┘
st   ───────────────────┘└─
1563      split,
src      └───┘
typ      └───┘
doc      └───┘
txt      └───┘
par      └───┘
st   ────────┘└─
1564      { assume a' a'_lt_a,
src        └───────────────┘
typ        └───────────────┘
doc        └───────────────┘
txt        └───────────────┘
par        └───────────────┘
pid        └───────────────┘
st   ─────┘└───────────────┘└─
1565        let ε := a - a',
id                     └┘
src        └───────┘  
typ        └───────┘ └┘
doc        └───────┘  
txt        └───────┘  
par        └───────┘  
pid        └───┘└─┘  
st   ────────────────────┘└─
1566        have : {b : β | |f b - a| < ε} ∈ x, from hyp_ε_pos ε (sub_pos.elim_right a'_lt_a),
id                                          └───────┘   └────────────────┘ └─────┘
src        └─────┘└──┘ └─┘      └┘    └───┘           └────────────────┘       
typ        └─────┘└──┘└─┘   └┘   └───┘└───────┘ └────────────────┘└─────┘
doc        └─────┘ └──┘ └─┘        └┘    └───┘                                    
txt        └─────┘ └──┘ └─┘        └┘    └───┘                                    
par        └─────┘ └──┘ └─┘        └┘    └───┘                                    
pid        └───┘└┘ └──┘ └─┘        └┘    └───┘                                    
st   ───────────────────────────────────────┘└─────────────────────────────────────────────┘└─
1567        have : {b : β | f b - a < ε ∧ a - f b < ε} ∈ x, by simpa only [abs_sub_lt_iff] using this,
id                                                                  └────────────┘        └──┘
src        └─────┘└──┘ └─┘             └┘       └──────────┘└────────────┘└──────┘
typ        └─────┘└──┘└─┘          └┘      └──────────┘└────────────┘└──────┘└──┘
doc        └─────┘ └──┘ └─┘             └┘       └──────────┘              └──────┘
txt        └─────┘ └──┘ └─┘             └┘       └──────────┘              └──────┘
par        └─────┘ └──┘ └─┘             └┘       └──────────┘              └──────┘
pid        └───┘└┘ └──┘ └─┘             └┘            └──┘└┘              └────┘
st   ───────────────────────────────────────────────────┘                                           └─
1568        have : {b : β | a - f b < ε} ∈ x, from x.sets_of_superset this (set.inter_subset_right _ _),
id                                          └────────────────┘ └──┘  └────────────────────┘
src        └─────┘└──┘ └─┘      └┘    └───┘└────────────────┘     └────────────────────┘└───┘
typ        └─────┘└──┘└─┘   └┘   └───┘└────────────────┘└──┘ └────────────────────┘└───┘
doc        └─────┘ └──┘ └─┘      └┘    └───┘                                             └───┘
txt        └─────┘ └──┘ └─┘      └┘    └───┘                                             └───┘
par        └─────┘ └──┘ └─┘      └┘    └───┘                                             └───┘
pid        └───┘└┘ └──┘ └─┘      └┘    └───┘                                             └───┘
st   ─────────────────────────────────────┘└─────────────────────────────────────────────────────────┘└─
1569        have : ∀ b, a' < f b ↔ a - f b < ε, by {intro b, rw [sub_lt, sub_sub_self] },
id                     └┘                                    └────┘  └──────────┘
src        └─────┘ └┘                   └─────┘  └──┘└────┘└┘└──────────┘└┘
typ        └─────┘ └┘ └┘             └─────┘  └──┘└────┘└┘└──────────┘└┘
doc        └─────┘ └┘                   └─────┘  └──┘      └┘            └┘
txt        └─────┘ └┘                   └─────┘  └──┘      └┘            └┘
par        └─────┘ └┘                   └─────┘  └──┘      └┘            └┘
pid        └───┘└┘ └┘                        └┘    └┘      └┘            
st   ───────────────────────────────────────┘     └─────┘└──────────┘└────────────┘└┘
1570        simpa only [this] },
id                     └──┘
src        └──────────┘    └┘
typ        └──────────┘└──┘└┘
doc        └──────────┘    └┘
txt        └──────────┘    └┘
par        └──────────┘    └┘
pid             └──┘└┘    
st   ───────────────────────┘└┘
1571      { assume a' a'_gt_a,
src        └───────────────┘
typ        └───────────────┘
doc        └───────────────┘
txt        └───────────────┘
par        └───────────────┘
pid        └───────────────┘
st   ──────────────────────┘└─
1572        let ε := a' - a,
id                  └┘   
src        └───────┘   
typ        └───────┘└┘ 
doc        └───────┘   
txt        └───────┘   
par        └───────┘   
pid        └───┘└─┘   
st   ────────────────────┘└─
1573        have : {b : β | |f b - a| < ε} ∈ x, from hyp_ε_pos ε (sub_pos.elim_right a'_gt_a),
id                                            └───────┘   └────────────────┘ └─────┘
src        └─────┘└──┘ └─┘        └┘    └───┘           └────────────────┘       
typ        └─────┘└──┘└─┘     └┘   └───┘└───────┘ └────────────────┘└─────┘
doc        └─────┘ └──┘ └─┘        └┘    └───┘                                    
txt        └─────┘ └──┘ └─┘        └┘    └───┘                                    
par        └─────┘ └──┘ └─┘        └┘    └───┘                                    
pid        └───┘└┘ └──┘ └─┘        └┘    └───┘                                    
st   ───────────────────────────────────────┘└─────────────────────────────────────────────┘└─
1574        have : {b : β | f b - a < ε ∧ a - f b < ε} ∈ x, by simpa only [abs_sub_lt_iff] using this,
id                                                                  └────────────┘        └──┘
src        └─────┘└──┘ └─┘             └┘       └──────────┘└────────────┘└──────┘
typ        └─────┘└──┘└─┘          └┘      └──────────┘└────────────┘└──────┘└──┘
doc        └─────┘ └──┘ └─┘             └┘       └──────────┘              └──────┘
txt        └─────┘ └──┘ └─┘             └┘       └──────────┘              └──────┘
par        └─────┘ └──┘ └─┘             └┘       └──────────┘              └──────┘
pid        └───┘└┘ └──┘ └─┘             └┘            └──┘└┘              └────┘
st   ───────────────────────────────────────────────────┘                                           └─
1575        have : {b : β | f b - a < ε} ∈ x, from x.sets_of_superset this (set.inter_subset_left _ _),
id                                          └────────────────┘ └──┘  └───────────────────┘
src        └─────┘└──┘ └─┘      └┘    └───┘└────────────────┘     └───────────────────┘└───┘
typ        └─────┘└──┘└─┘   └┘   └───┘└────────────────┘└──┘ └───────────────────┘└───┘
doc        └─────┘ └──┘ └─┘      └┘    └───┘                                            └───┘
txt        └─────┘ └──┘ └─┘      └┘    └───┘                                            └───┘
par        └─────┘ └──┘ └─┘      └┘    └───┘                                            └───┘
pid        └───┘└┘ └──┘ └─┘      └┘    └───┘                                            └───┘
st   ─────────────────────────────────────┘└────────────────────────────────────────────────────────┘└─
1576        have : ∀ b, f b < a' ↔ f b - a < ε, by { intro b, simp [lt_sub_iff_add_lt] },
id                           └┘                                 └───────────────┘
src        └─────┘ └┘                    └─────┘  └────┘└───────────────┘└┘
typ        └─────┘ └┘    └┘           └─────┘  └────┘└───────────────┘└┘
doc        └─────┘ └┘                    └─────┘  └────┘                 └┘
txt        └─────┘ └┘                    └─────┘  └────┘                 └┘
par        └─────┘ └┘                    └─────┘  └────┘                 └┘
pid        └───┘└┘ └┘                         └┘                       
st   ───────────────────────────────────────┘     └──────┘└─────────────────────────┘└┘
1577        simpa only [this] }}
id                     └──┘
src        └──────────┘    └┘
typ        └──────────┘└──┘└┘
doc        └──────────┘    └┘
txt        └──────────┘    └┘
par        └──────────┘    └┘
pid             └──┘└┘    
st   ───────────────────────┘└──
1578  end
st   ──┘